restorecond: add check for strdup in strings_list_add
Check the return value of strdup() to avoid null pointer reference. Signed-off-by: Huaxin Lu <luhuaxin1@huawei.com> Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
a7e975285c
commit
8730e0762e
|
@ -48,6 +48,8 @@ void strings_list_add(struct stringsList **list, const char *string)
|
|||
if (!newptr)
|
||||
exitApp("Out of Memory");
|
||||
newptr->string = strdup(string);
|
||||
if (!newptr->string)
|
||||
exitApp("Out of Memory");
|
||||
newptr->next = ptr;
|
||||
if (prev)
|
||||
prev->next = newptr;
|
||||
|
|
Loading…
Reference in New Issue