[PATCH 03/32] [libx11] Using uninitialized value "p->modifiers"
Mark Kettenis
mark.kettenis at xs4all.nl
Sat Feb 12 15:04:07 PST 2011
> From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= <erkki.seppala at vincit.fi>
> Date: Thu, 27 Jan 2011 09:53:46 +0200
>
> Smal fix by using calloc instead of Xmalloc
The comments introduced here (especially the first one) are fairly pointless.
And this probably should use Xcalloc() instead of calloc().
> ---
> 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);
> }
More information about the xorg-devel
mailing list