From e189dbb3e57d30eb96034d4ce9544ce7a93a371e Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 28 Oct 2011 20:19:44 -0700 Subject: Convert AllocXTestDevice to use asprintf Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston --- Xext/xtest.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Xext/xtest.c b/Xext/xtest.c index 945e202d6..b69de35f6 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -608,12 +608,11 @@ int AllocXTestDevice (ClientPtr client, char* name, DeviceIntPtr master_ptr, DeviceIntPtr master_keybd) { int retval; - int len = strlen(name); - char *xtestname = calloc(len + 7, 1 ); + char *xtestname; char dummy = 1; - strncpy( xtestname, name, len); - strncat( xtestname, " XTEST", 6 ); + if (asprintf(&xtestname, "%s XTEST", name) == -1) + return BadAlloc; retval = AllocDevicePair( client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE); if ( retval == Success ){ -- cgit v1.2.3