From: Jaroslav Kysela Date: Sat, 19 Mar 2011 00:09:41 +0000 (+0100) Subject: UCM: Fix empty get_list - initialize returned pointer to NULL X-Git-Tag: v1.0.25~47 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=f2912f5099e401cebacd33bd9da3d8318856e143;p=alsa-lib.git UCM: Fix empty get_list - initialize returned pointer to NULL Signed-off-by: Jaroslav Kysela --- diff --git a/src/ucm/main.c b/src/ucm/main.c index 5de8170c..9b450f66 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -75,8 +75,10 @@ static int alloc_str_list(struct list_head *list, int mult, char **result[]) int cnt; cnt = list_count(list) * mult; - if (cnt == 0) + if (cnt == 0) { + *result = NULL; return cnt; + } res = calloc(mult, cnt * sizeof(char *)); if (res == NULL) return -ENOMEM; @@ -912,8 +914,8 @@ static int get_value_list(snd_use_case_mgr_t *uc_mgr, goto __fail; } err = alloc_str_list(&mylist, 1, &res); - *list = (const char **)res; if (err >= 0) { + *list = (const char **)res; list_for_each(pos, &mylist) { val = list_entry(pos, struct myvalue, list); *res = strdup(val->value);