[PATCH 3/8] Free keymap on error in Xephyr's hostx_load_keymap
Alan Coopersmith
alan.coopersmith at oracle.com
Mon Jan 28 17:08:37 PST 2013
Found by parfait 1.1 code analyser:
Memory leak of pointer 'keymap' allocated with XGetKeyboardMapping(HostX.dpy, min_keycode, ((max_keycode - min_keycode) + 1), &host_width)
at line 861 of hw/kdrive/ephyr/hostx.c in function 'hostx_load_keymap'.
'keymap' allocated at line 845 with XGetKeyboardMapping(HostX.dpy, min_keycode, ((max_keycode - min_keycode) + 1), &host_width).
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
hw/kdrive/ephyr/hostx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 157ac36..aed0285 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -858,7 +858,7 @@ hostx_load_keymap(void)
(max_keycode - min_keycode + 1) *
width);
if (!ephyrKeySyms.map)
- return;
+ goto out;
for (i = 0; i < (max_keycode - min_keycode + 1); i++)
for (j = 0; j < width; j++)
@@ -871,6 +871,7 @@ hostx_load_keymap(void)
ephyrKeySyms.maxKeyCode = max_keycode;
ephyrKeySyms.mapWidth = width;
+ out:
XFree(keymap);
}
--
1.7.9.2
More information about the xorg-devel
mailing list