summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2007-11-15 16:23:48 +1030
committerPeter Hutterer <peter@cs.unisa.edu.au>2007-11-15 16:23:48 +1030
commit53539688cab990a7df1851d64f3ee4e11920a86b (patch)
tree9d1895722ec1670ae6dd20257c394f2ef1da83f4
parentb40646dc104fb03ea7cc0b27fae573aecaab486e (diff)
dix: SetKeySymMap should alloc the map if dst doesn't have one already.
-rw-r--r--dix/devices.c12
1 files 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,