mirror of https://github.com/ericonr/sndio.git
Fix memory leak in the error handling code path of failed device
creation. From jsg@
This commit is contained in:
parent
cb82b78c1c
commit
9f12e52145
10
aucat/dev.c
10
aucat/dev.c
|
@ -115,11 +115,6 @@ dev_new(char *path, unsigned mode,
|
||||||
struct dev *d;
|
struct dev *d;
|
||||||
unsigned *pnum, i;
|
unsigned *pnum, i;
|
||||||
|
|
||||||
d = malloc(sizeof(struct dev));
|
|
||||||
if (d == NULL) {
|
|
||||||
perror("malloc");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
pnum = (mode & MODE_THRU) ? &dev_thrnum : &dev_sndnum;
|
pnum = (mode & MODE_THRU) ? &dev_thrnum : &dev_sndnum;
|
||||||
if (*pnum == DEV_NMAX) {
|
if (*pnum == DEV_NMAX) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -128,6 +123,11 @@ dev_new(char *path, unsigned mode,
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
d = malloc(sizeof(struct dev));
|
||||||
|
if (d == NULL) {
|
||||||
|
perror("malloc");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
d->num = (*pnum)++;
|
d->num = (*pnum)++;
|
||||||
if (mode & MODE_THRU)
|
if (mode & MODE_THRU)
|
||||||
d->num += DEV_NMAX;
|
d->num += DEV_NMAX;
|
||||||
|
|
Loading…
Reference in New Issue