From 92d9cb7e1340b259294ba317ea3a7d18487498b5 Mon Sep 17 00:00:00 2001 From: Tomas Carnecky Date: Sun, 6 Dec 2009 23:52:54 +0100 Subject: XkbWriteCountedString(): return early if str is NULL This avoids NULL from being passed to memcpy() later in the code. While that wasn't an issue before - that value being NULL implied 'size == 0' so memcpy() wouldn't try to dereference it - it made the code harder to read and also confused clang. Signed-off-by: Tomas Carnecky Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- xkb/xkb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'xkb') diff --git a/xkb/xkb.c b/xkb/xkb.c index 98e879ddb..00ae29cd7 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -4298,9 +4298,12 @@ ProcXkbSetNames(ClientPtr client) static char * XkbWriteCountedString(char *wire,char *str,Bool swap) { -CARD16 len,*pLen; + CARD16 len,*pLen; - len= (str?strlen(str):0); + if (!str) + return wire; + + len= strlen(str); pLen= (CARD16 *)wire; *pLen= len; if (swap) { -- cgit v1.2.3