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:
Alan Coopersmith
2011-10-24 23:16:30 -07:00
parent acde97a39d
commit 08093c25a9
3 changed files with 4 additions and 11 deletions

View File

@@ -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;