Consider strings empty for string_new_length(NULL)

This commit is contained in:
Pierre Pronchery 2017-04-14 03:44:13 +02:00
parent 6d13c18543
commit 6324df6d88

View File

@ -108,7 +108,7 @@ String * string_new_length(String const * string, size_t length)
#endif #endif
if((ret = object_new(++length)) == NULL) if((ret = object_new(++length)) == NULL)
return NULL; return NULL;
snprintf(ret, length, "%s", string); snprintf(ret, length, "%s", (string != NULL) ? string : "");
return ret; return ret;
} }