Skip to content

Commit

Permalink
restorecond: add check for strdup in strings_list_add
Browse files Browse the repository at this point in the history
Check the return value of strdup() to avoid null pointer reference.

Signed-off-by: Huaxin Lu <[email protected]>
Acked-by: James Carter <[email protected]>
  • Loading branch information
Huaxin Lu authored and jwcart2 committed Aug 4, 2023
1 parent a7e9752 commit 8730e07
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions restorecond/stringslist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8730e07

Please sign in to comment.