[PATCH 03/32] [libx11] Using uninitialized value "p->modifiers"
Erkki Seppälä
erkki.seppala at vincit.fi
Wed Jan 26 23:53:46 PST 2011
Smal fix by using calloc instead of Xmalloc
Reviewed-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira at nokia.com>
Signed-off-by: Erkki Seppälä <erkki.seppala at vincit.fi>
---
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
More information about the xorg-devel
mailing list