[PATCH v2 xserver 2/2] xkb: Prevent leaking of XKB geometry information on copy.

Rami Ylimäki rami.ylimaki at vincit.fi
Wed Mar 30 06:47:31 PDT 2011


Currently shapes, sections and doodads may leak on copy.

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Erkki Seppälä <erkki.seppala at vincit.fi>
Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
---
 xkb/xkbUtils.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 7fea194..323731f 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1538,10 +1538,10 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
         }
 
         if (src->geom->num_shapes) {
-            tmp = calloc(src->geom->num_shapes, sizeof(XkbShapeRec));
-            if (!tmp)
+            /* Reallocate and clear all items. */
+            if (!XkbGeomRealloc((void **)&dst->geom->shapes, dst->geom->sz_shapes, src->geom->num_shapes,
+                                sizeof(XkbShapeRec), XKB_GEOM_CLEAR_ALL))
                 return FALSE;
-            dst->geom->shapes = tmp;
 
             for (i = 0, sshape = src->geom->shapes, dshape = dst->geom->shapes;
                  i < src->geom->num_shapes;
@@ -1658,7 +1658,6 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
             }
 
             dst->geom->num_sections = 0;
-            dst->geom->sections = NULL;
         }
 
         if (src->geom->num_sections) {
@@ -1768,7 +1767,6 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
                 }
             }
             dst->geom->num_doodads = 0;
-            dst->geom->doodads = NULL;
         }
 
         if (src->geom->num_doodads) {
-- 
1.6.3.3



More information about the xorg-devel mailing list