Handle allocation error in strndup to avoid access violation.
Return NULL before calling strncpy. Platforms with HAVE_STRNDUP are not affected.
This commit is contained in:
@@ -50,6 +50,8 @@
|
||||
{
|
||||
size_t strsize = strnlen(__string, __n);
|
||||
char *newstr = (char *)malloc(strsize + 1);
|
||||
if (newstr == NULL)
|
||||
return NULL;
|
||||
|
||||
strncpy(newstr, __string, strsize);
|
||||
newstr[strsize] = 0;
|
||||
|
||||
Reference in New Issue
Block a user