mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 00:25:43 +01:00
alsaucm: Don't double-free empty lists
When snd_use_case_get_list (and hence also snd_use_case_card_list) returns an empty list, alsaucm still attempts to free it. This ends up double- freeing the returned list, or worse, freeing an invalid pointer, depending on how snd_use_case_get_list gets implemented. Fix alsaucm to return early on empty lists to avoid this. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
16bdb41b87
commit
f30fbe3901
1 changed files with 6 additions and 2 deletions
|
@ -226,8 +226,10 @@ static int do_one(struct context *context, struct cmd *cmd, char **argv)
|
||||||
snd_strerror(err));
|
snd_strerror(err));
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (err == 0)
|
if (err == 0) {
|
||||||
printf(" list is empty\n");
|
printf(" list is empty\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
for (i = 0; i < err / 2; i++) {
|
for (i = 0; i < err / 2; i++) {
|
||||||
printf(" %i: %s\n", i, list[i*2]);
|
printf(" %i: %s\n", i, list[i*2]);
|
||||||
if (list[i*2+1])
|
if (list[i*2+1])
|
||||||
|
@ -256,8 +258,10 @@ static int do_one(struct context *context, struct cmd *cmd, char **argv)
|
||||||
snd_strerror(err));
|
snd_strerror(err));
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (err == 0)
|
if (err == 0) {
|
||||||
printf(" list is empty\n");
|
printf(" list is empty\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
for (i = 0; i < err / entries; i++) {
|
for (i = 0; i < err / entries; i++) {
|
||||||
printf(" %i: %s\n", i, list[i*entries]);
|
printf(" %i: %s\n", i, list[i*entries]);
|
||||||
for (j = 0; j < entries - 1; j++)
|
for (j = 0; j < entries - 1; j++)
|
||||||
|
|
Loading…
Reference in a new issue