diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-03-16 10:03:13 -0700 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2016-10-12 09:34:39 +0200 |
commit | 37f8d3eb8ec4a44bebaac7893e5881bd59b5440c (patch) | |
tree | 49995aebcd718285274ab593abc70f037ecb5244 | |
parent | e386187e91569eae3064927d5b5753a7a68ace47 (diff) | |
download | nx-libs-37f8d3eb8ec4a44bebaac7893e5881bd59b5440c.tar.gz nx-libs-37f8d3eb8ec4a44bebaac7893e5881bd59b5440c.tar.bz2 nx-libs-37f8d3eb8ec4a44bebaac7893e5881bd59b5440c.zip |
Use calloc in XOpenDisplay to initialize structs containing pointers
Prevents trying to free uninitialized pointers if we have to bail out
partway through setup, such as if we receive a corrupted or incomplete
connection setup block from the server.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Julien Cristau <jcristau@debian.org>
Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
-rw-r--r-- | nx-X11/lib/X11/OpenDis.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/nx-X11/lib/X11/OpenDis.c b/nx-X11/lib/X11/OpenDis.c index a4b80633b..4036572a8 100644 --- a/nx-X11/lib/X11/OpenDis.c +++ b/nx-X11/lib/X11/OpenDis.c @@ -549,9 +549,7 @@ fallback_success: /* * Now iterate down setup information..... */ - dpy->pixmap_format = - (ScreenFormat *)Xmalloc( - (unsigned) (dpy->nformats *sizeof(ScreenFormat))); + dpy->pixmap_format = Xcalloc(dpy->nformats, sizeof(ScreenFormat)); if (dpy->pixmap_format == NULL) { OutOfMemory (dpy, setup); return(NULL); @@ -579,8 +577,7 @@ fallback_success: /* * next the Screen structures. */ - dpy->screens = - (Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen)); + dpy->screens = Xcalloc(dpy->nscreens, sizeof(Screen)); if (dpy->screens == NULL) { OutOfMemory (dpy, setup); return(NULL); @@ -622,8 +619,7 @@ fallback_success: /* * lets set up the depth structures. */ - sp->depths = (Depth *)Xmalloc( - (unsigned)sp->ndepths*sizeof(Depth)); + sp->depths = Xcalloc(sp->ndepths, sizeof(Depth)); if (sp->depths == NULL) { OutOfMemory (dpy, setup); return(NULL); @@ -645,8 +641,7 @@ fallback_success: dp->nvisuals = u.dp->nVisuals; u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth); if (dp->nvisuals > 0) { - dp->visuals = - (Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual)); + dp->visuals = Xcalloc(dp->nvisuals, sizeof(Visual)); if (dp->visuals == NULL) { OutOfMemory (dpy, setup); return(NULL); |