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 <tom@dbservice.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
df2635d464
commit
92d9cb7e13
|
@ -4298,9 +4298,12 @@ ProcXkbSetNames(ClientPtr client)
|
||||||
static char *
|
static char *
|
||||||
XkbWriteCountedString(char *wire,char *str,Bool swap)
|
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= (CARD16 *)wire;
|
||||||
*pLen= len;
|
*pLen= len;
|
||||||
if (swap) {
|
if (swap) {
|
||||||
|
|
Loading…
Reference in New Issue