Smal fix by using calloc instead of Xmalloc
Reviewed-by: Ander Conselvan de Oliveira <[email protected]>
Signed-off-by: Erkki Seppälä <[email protected]>
---
src/KeyBind.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/KeyBind.c b/src/KeyBind.c
index 6d80a02..5b78efc 100644
--- a/src/KeyBind.c
+++ b/src/KeyBind.c
@@ -46,6 +46,7 @@ in this Software without prior written authorization from The
Open Group.
#define XK_XKB_KEYS
#include <X11/keysymdef.h>
#include <stdio.h>
+#include <stdlib.h>
#ifdef USE_OWN_COMPOSE
#include "imComp.h"
@@ -996,13 +997,15 @@ XRebindKeysym (
tmp = dpy->key_bindings;
nb = sizeof(KeySym) * nm;
- if ((! (p = (struct _XKeytrans *) Xmalloc( sizeof(struct _XKeytrans)))) ||
+ /* using calloc to zero the contents of allocated structure */
+ if ((! (p = (struct _XKeytrans *) calloc( 1, sizeof(struct _XKeytrans))))
||
((! (p->string = (char *) Xmalloc( (unsigned) nbytes))) &&
(nbytes > 0)) ||
((! (p->modifiers = (KeySym *) Xmalloc( (unsigned) nb))) &&
(nb > 0))) {
if (p) {
if (p->string) Xfree(p->string);
+ /* without calloc, p->modifiers could end up being uninitialized */
if (p->modifiers) Xfree((char *) p->modifiers);
Xfree((char *) p);
}
--
1.7.0.4
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel