[alsa-devel] [PATCH] ucm: Return NULL from get_list0() and get_list20() in case of empty lists.
alloc_str_list() sets the result to NULL too, so this patch makes the behavior more consistent. This also fixes a crash in PulseAudio, because PulseAudio assumes that snd_use_case_get_list() always initializes the result, and since snd_use_case_get_list() uses get_list20(), this assumption didn't hold. --- src/ucm/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/ucm/main.c b/src/ucm/main.c index 79901f8..4b37776 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -367,8 +367,10 @@ static int get_list0(struct list_head *list, char *ptr, *str1;
cnt = alloc_str_list(list, 1, &res); - if (cnt <= 0) + if (cnt <= 0) { + *result = NULL; return cnt; + } *result = (const char **)res; list_for_each(pos, list) { ptr = list_entry_offset(pos, char, offset); @@ -414,8 +416,10 @@ static int get_list20(struct list_head *list, char *ptr, *str1, *str2;
cnt = alloc_str_list(list, 2, &res); - if (cnt <= 0) + if (cnt <= 0) { + *result = NULL; return cnt; + } *result = (const char **)res; list_for_each(pos, list) { ptr = list_entry_offset(pos, char, offset);
At Wed, 1 Aug 2012 16:06:16 +0300, Tanu Kaskinen wrote:
alloc_str_list() sets the result to NULL too, so this patch makes the behavior more consistent. This also fixes a crash in PulseAudio, because PulseAudio assumes that snd_use_case_get_list() always initializes the result, and since snd_use_case_get_list() uses get_list20(), this assumption didn't hold.
Applied now. Thanks.
Takashi
src/ucm/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/ucm/main.c b/src/ucm/main.c index 79901f8..4b37776 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -367,8 +367,10 @@ static int get_list0(struct list_head *list, char *ptr, *str1;
cnt = alloc_str_list(list, 1, &res);
- if (cnt <= 0)
- if (cnt <= 0) {
*result = NULL; return cnt;
- } *result = (const char **)res; list_for_each(pos, list) { ptr = list_entry_offset(pos, char, offset);
@@ -414,8 +416,10 @@ static int get_list20(struct list_head *list, char *ptr, *str1, *str2;
cnt = alloc_str_list(list, 2, &res);
- if (cnt <= 0)
- if (cnt <= 0) {
*result = NULL; return cnt;
- } *result = (const char **)res; list_for_each(pos, list) { ptr = list_entry_offset(pos, char, offset);
-- 1.7.9.5
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
participants (2)
-
Takashi Iwai
-
Tanu Kaskinen