Convert some malloc + strncpy pairs into strndup calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
This commit is contained in:
@@ -118,14 +118,11 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
|
||||
}
|
||||
else
|
||||
{
|
||||
char *newstring = malloc(len + 1);
|
||||
if (!newstring) {
|
||||
nd->string = strndup(string, len);
|
||||
if (!nd->string) {
|
||||
free(nd);
|
||||
return BAD_RESOURCE;
|
||||
}
|
||||
strncpy(newstring, string, (int)len);
|
||||
newstring[len] = 0;
|
||||
nd->string = newstring;
|
||||
}
|
||||
if ((lastAtom + 1) >= tableLength) {
|
||||
NodePtr *table;
|
||||
|
||||
Reference in New Issue
Block a user