From 08093c25a91c07ab8af7cece9bba738b827cfd1b Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 24 Oct 2011 23:16:30 -0700 Subject: Convert some malloc + strncpy pairs into strndup calls Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston --- dix/atom.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'dix/atom.c') diff --git a/dix/atom.c b/dix/atom.c index 88b40db65..83ff71a7d 100644 --- a/dix/atom.c +++ b/dix/atom.c @@ -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; -- cgit v1.2.3