diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-09-23 11:43:27 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-09-25 08:17:03 +1000 |
commit | a9c274df5c37cb4ece6449e934342d8ff8e61705 (patch) | |
tree | 4ece210923feed50e6fb63674ed21f2072b55702 | |
parent | fd913136732ff14a0484ca28f60ac1fbf49be81d (diff) |
kdrive: plug two memory leaks when freeing the KdKeyboard/Pointer.
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@who-t.net>
-rw-r--r-- | hw/kdrive/ephyr/ephyr.c | 4 | ||||
-rw-r--r-- | 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 296284a01..254fcbc54 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -1071,12 +1071,14 @@ MouseInit (KdPointerInfo *pi) { pi->driverPrivate = (EphyrPointerPrivate *) xcalloc(sizeof(EphyrPointerPrivate), 1); ((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; } static Status @@ -1120,12 +1122,14 @@ EphyrKeyboardInit (KdKeyboardInfo *ki) if (!ephyrKeySyms.map) { ErrorF("Couldn't load keymap from host\n"); return BadAlloc; } ki->minScanCode = ephyrKeySyms.minKeyCode; ki->maxScanCode = ephyrKeySyms.maxKeyCode; + if (ki->name) + xfree(ki->name); ki->name = strdup("Xephyr virtual keyboard"); ephyrKbd = ki; return Success; } static Status diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c index cb646130e..4551fd76b 100644 --- a/hw/kdrive/src/kinfo.c +++ b/hw/kdrive/src/kinfo.c @@ -163,9 +163,15 @@ void KdFreeKeyboard(KdKeyboardInfo *ki) { if (ki->name) 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); } |