mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-28 17:06:22 +00:00
Added more tests to str_replace
Handles NULLs and empty strings better
This commit is contained in:
7
util.c
7
util.c
@@ -62,7 +62,12 @@ char * str_replace (const char *string, const char *substr,
|
||||
char *oldstr = NULL;
|
||||
char *head = NULL;
|
||||
|
||||
if ( substr == NULL || replacement == NULL )
|
||||
if (string == NULL)
|
||||
return NULL;
|
||||
|
||||
if ( substr == NULL ||
|
||||
replacement == NULL ||
|
||||
(strcmp(substr, "") == 0))
|
||||
return strdup (string);
|
||||
|
||||
newstr = strdup (string);
|
||||
|
||||
Reference in New Issue
Block a user