summaryrefslogtreecommitdiff
path: root/xkb
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2006-12-08 21:31:47 +0200
committerDaniel Stone <daniels@endtroducing.fooishbar.org>2006-12-08 21:31:51 +0200
commitec84f72d077eaf2e7768a1f5398f65a5e1714d08 (patch)
treef3469933cc1c6abdbc0a17d2c230759c16ba5149 /xkb
parente59aeac1ff13ea53f44dba1ac7800f37f4532ca1 (diff)
XkbCopyKeymap: always initialise map and preserve
If we don't have map or preserve in the source map, make sure the destination is initialised to NULL, and freed if it's a valid type.
Diffstat (limited to 'xkb')
-rw-r--r--xkb/xkbUtils.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 321bf2e1b..c9c5ed018 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1144,6 +1144,11 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
memcpy(dtype->map, stype->map,
stype->map_count * sizeof(XkbKTMapEntryRec));
}
+ else {
+ if (dtype->map && i < dst->map->num_types)
+ xfree(dtype->map);
+ dtype->map = NULL;
+ }
if (stype->preserve) {
if (stype->map_count != dtype->map_count &&
@@ -1168,17 +1173,22 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
memcpy(dtype->preserve, stype->preserve,
stype->map_count * sizeof(XkbModsRec));
}
+ else {
+ if (dtype->preserve && i < dst->map->num_types)
+ xfree(dtype->preserve);
+ dtype->preserve = NULL;
+ }
dtype->map_count = stype->map_count;
}
else {
- if (dtype->map_count) {
+ if (dtype->map_count && i < dst->map->num_types) {
if (dtype->map)
xfree(dtype->map);
if (dtype->preserve)
xfree(dtype->preserve);
- dtype->map_count = 0;
}
+ dtype->map_count = 0;
dtype->map = NULL;
dtype->preserve = NULL;
}