From 53539688cab990a7df1851d64f3ee4e11920a86b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 15 Nov 2007 16:23:48 +1030 Subject: [PATCH] dix: SetKeySymMap should alloc the map if dst doesn't have one already. --- dix/devices.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index bf1126f66..1792e9e3f 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -1046,10 +1046,9 @@ SetKeySymsMap(KeySymsPtr dst, KeySymsPtr src) KeySym *map; int bytes = sizeof(KeySym) * src->mapWidth * (dst->maxKeyCode - dst->minKeyCode + 1); - map = (KeySym *)xalloc(bytes); + map = (KeySym *)xcalloc(1, bytes); if (!map) return FALSE; - bzero((char *)map, bytes); if (dst->map) { for (i = 0; i <= dst->maxKeyCode-dst->minKeyCode; i++) @@ -1060,6 +1059,15 @@ SetKeySymsMap(KeySymsPtr dst, KeySymsPtr src) } dst->mapWidth = src->mapWidth; dst->map = map; + } else if (!dst->map) + { + KeySym *map; + int bytes = sizeof(KeySym) * src->mapWidth * + (dst->maxKeyCode - dst->minKeyCode + 1); + map = (KeySym *)xcalloc(1, bytes); + if (!map) + return FALSE; + dst->map = map; } memmove((char *)&dst->map[rowDif * dst->mapWidth], (char *)src->map,