[PATCH] kdrive: plug two memory leaks when freeing the KdKeyboard/Pointer.
Peter Hutterer
peter.hutterer at who-t.net
Tue Sep 22 23:30:52 PDT 2009
xkbRules, xkbModel and xkbLayout are strdup'd in KdNewKeyboard, need to be
freed.
The ephyr driver strdups the name on top of the already allocated
kdrive-assigned name. Memory must be freed beforehand.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
hw/kdrive/ephyr/ephyr.c | 4 ++++
hw/kdrive/src/kinfo.c | 6 ++++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 296284a..254fcbc 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -1074,6 +1074,8 @@ MouseInit (KdPointerInfo *pi)
((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
pi->nAxes = 3;
pi->nButtons = 32;
+ if (pi->name)
+ xfree(pi->name);
pi->name = strdup("Xephyr virtual mouse");
ephyrMouse = pi;
return Success;
@@ -1123,6 +1125,8 @@ EphyrKeyboardInit (KdKeyboardInfo *ki)
}
ki->minScanCode = ephyrKeySyms.minKeyCode;
ki->maxScanCode = ephyrKeySyms.maxKeyCode;
+ if (ki->name)
+ xfree(ki->name);
ki->name = strdup("Xephyr virtual keyboard");
ephyrKbd = ki;
return Success;
diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c
index cb64613..4551fd7 100644
--- a/hw/kdrive/src/kinfo.c
+++ b/hw/kdrive/src/kinfo.c
@@ -166,6 +166,12 @@ KdFreeKeyboard(KdKeyboardInfo *ki)
xfree(ki->name);
if (ki->path)
xfree(ki->path);
+ if (ki->xkbRules)
+ xfree(ki->xkbRules);
+ if (ki->xkbModel)
+ xfree(ki->xkbModel);
+ if (ki->xkbLayout)
+ xfree(ki->xkbLayout);
ki->next = NULL;
xfree(ki);
}
--
1.6.3.rc1.2.g0164.dirty
More information about the xorg-devel
mailing list