alsaloop: fix possible memory leak in create_loopback_handle()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-01-08 18:21:39 +01:00
parent c5ecfd9789
commit 90bbeb1d3e

View file

@ -85,12 +85,17 @@ static int create_loopback_handle(struct loopback_handle **_handle,
if (device == NULL)
device = "hw:0,0";
handle->device = strdup(device);
if (handle->device == NULL)
if (handle->device == NULL) {
free(handle);
return -ENOMEM;
}
if (ctldev) {
handle->ctldev = strdup(ctldev);
if (handle->ctldev == NULL)
if (handle->ctldev == NULL) {
free(handle->device);
free(handle);
return -ENOMEM;
}
} else {
handle->ctldev = NULL;
}