From 9779025f33c917b74349200e6018d0c94d6ff0ab Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Mon, 3 Apr 2006 01:10:02 +0000 Subject: Coverity #428: Fix a potential NULL chase. Coverity #930: Verify that a malloc succeeds. --- src/Xrender.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Xrender.c b/src/Xrender.c index 8d8aeb9..3a51663 100644 --- a/src/Xrender.c +++ b/src/Xrender.c @@ -294,7 +294,7 @@ static int XRenderCloseDisplay (Display *dpy, XExtCodes *codes) { XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - if (info->info) XFree (info->info); + if (info && info->info) XFree (info->info); return XRenderExtRemoveDisplay (&XRenderExtensionInfo, dpy); } @@ -463,16 +463,6 @@ XRenderQueryFormats (Display *dpy) rep.numScreens * sizeof (XRenderScreen) + rep.numDepths * sizeof (XRenderDepth) + rep.numVisuals * sizeof (XRenderVisual)); - xri->major_version = async_state.major_version; - xri->minor_version = async_state.minor_version; - xri->format = (XRenderPictFormat *) (xri + 1); - xri->nformat = rep.numFormats; - xri->screen = (XRenderScreen *) (xri->format + rep.numFormats); - xri->nscreen = rep.numScreens; - xri->depth = (XRenderDepth *) (xri->screen + rep.numScreens); - xri->ndepth = rep.numDepths; - xri->visual = (XRenderVisual *) (xri->depth + rep.numDepths); - xri->nvisual = rep.numVisuals; rlength = (rep.numFormats * sizeof (xPictFormInfo) + rep.numScreens * sizeof (xPictScreen) + rep.numDepths * sizeof (xPictDepth) + @@ -490,6 +480,16 @@ XRenderQueryFormats (Display *dpy) SyncHandle (); return 0; } + xri->major_version = async_state.major_version; + xri->minor_version = async_state.minor_version; + xri->format = (XRenderPictFormat *) (xri + 1); + xri->nformat = rep.numFormats; + xri->screen = (XRenderScreen *) (xri->format + rep.numFormats); + xri->nscreen = rep.numScreens; + xri->depth = (XRenderDepth *) (xri->screen + rep.numScreens); + xri->ndepth = rep.numDepths; + xri->visual = (XRenderVisual *) (xri->depth + rep.numDepths); + xri->nvisual = rep.numVisuals; _XRead (dpy, (char *) xData, rlength); format = xri->format; xFormat = (xPictFormInfo *) xData; -- cgit v1.2.3