summaryrefslogtreecommitdiff
path: root/xkb/xkbUtils.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2008-02-07 15:48:04 +1030
committerPeter Hutterer <peter@cs.unisa.edu.au>2008-02-09 07:55:38 +1030
commit7018f280406eb0ef899a4046de274cfdd582881b (patch)
tree21edd8f72d8f2419b9acd8d58af9437e7ed1983b /xkb/xkbUtils.c
parent66f8001b61d12eaf4905ac71ccbb3f304914d00d (diff)
xkb: when copying the keymap, make sure the structs default to 0/NULL.
It actually does help if a pointer is NULL rather than pointing to nirvana when you're trying to free it lateron. Who would have thought?
Diffstat (limited to 'xkb/xkbUtils.c')
-rw-r--r--xkb/xkbUtils.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 9f813e5e3..3cedf825a 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1730,9 +1730,8 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
else {
if (dst->geom->sz_shapes) {
xfree(dst->geom->shapes);
- dst->geom->shapes = NULL;
}
-
+ dst->geom->shapes = NULL;
dst->geom->num_shapes = 0;
dst->geom->sz_shapes = 0;
}
@@ -1781,6 +1780,7 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
}
dst->geom->num_sections = 0;
+ dst->geom->sections = NULL;
}
if (src->geom->num_sections) {
@@ -1792,6 +1792,7 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
tmp = xalloc(src->geom->num_sections * sizeof(XkbSectionRec));
if (!tmp)
return FALSE;
+ memset(tmp, 0, src->geom->num_sections * sizeof(XkbSectionRec));
dst->geom->sections = tmp;
dst->geom->num_sections = src->geom->num_sections;
@@ -1828,6 +1829,10 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
return FALSE;
dsection->doodads = tmp;
}
+ else {
+ dsection->doodads = NULL;
+ }
+
for (k = 0,
sdoodad = ssection->doodads,
ddoodad = dsection->doodads;
@@ -1855,9 +1860,9 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
else {
if (dst->geom->sz_sections) {
xfree(dst->geom->sections);
- dst->geom->sections = NULL;
}
+ dst->geom->sections = NULL;
dst->geom->num_sections = 0;
dst->geom->sz_sections = 0;
}
@@ -1886,6 +1891,8 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
}
}
}
+ dst->geom->num_doodads = 0;
+ dst->geom->doodads = NULL;
}
if (src->geom->num_doodads) {
@@ -1898,7 +1905,7 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
sizeof(XkbDoodadRec));
if (!tmp)
return FALSE;
- bzero(tmp, src->geom->num_doodads * sizeof(XkbDoodadRec));
+ memset(tmp, 0, src->geom->num_doodads * sizeof(XkbDoodadRec));
dst->geom->doodads = tmp;
dst->geom->sz_doodads = src->geom->num_doodads;
@@ -1927,9 +1934,9 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
else {
if (dst->geom->sz_doodads) {
xfree(dst->geom->doodads);
- dst->geom->doodads = NULL;
}
+ dst->geom->doodads = NULL;
dst->geom->num_doodads = 0;
dst->geom->sz_doodads = 0;
}
@@ -1957,10 +1964,10 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
dst->geom->num_key_aliases = dst->geom->sz_key_aliases;
}
else {
- if (dst->geom->sz_key_aliases && dst->geom->key_aliases) {
+ if (dst->geom->key_aliases) {
xfree(dst->geom->key_aliases);
- dst->geom->key_aliases = NULL;
}
+ dst->geom->key_aliases = NULL;
dst->geom->num_key_aliases = 0;
dst->geom->sz_key_aliases = 0;
}
@@ -1991,8 +1998,8 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
else {
if (dst->geom->label_font) {
xfree(dst->geom->label_font);
- dst->geom->label_font = NULL;
}
+ dst->geom->label_font = NULL;
dst->geom->label_color = NULL;
dst->geom->base_color = NULL;
}