Skip to content
Snippets Groups Projects
Commit 28f87711 authored by Travis Glenn Hansen's avatar Travis Glenn Hansen
Browse files

Merge pull request #11 from elliotkendall/realloc

Check for failure of realloc
parents bf7ddcff 16ce182c
No related branches found
No related tags found
No related merge requests found
......@@ -680,6 +680,8 @@ void str_swap_free (char **target, char *source)
char *str_append (char *target, const char *data)
{
char *newtarget;
if (data == NULL) {
return target;
}
......@@ -690,9 +692,14 @@ char *str_append (char *target, const char *data)
}
int len = strlen (target) + strlen (data) + 1;
target = realloc (target, len);
newtarget = realloc (target, len);
if (newtarget == NULL) {
fanout_error ("ERROR unable to allocate memory");
exit (EXIT_FAILURE);
}
newtarget = strcat (newtarget, data);
return strcat (target, data);
return newtarget;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment