Commit d8012d2a authored by Ulrich Sibiller's avatar Ulrich Sibiller

Screen.c: safe some lines by calling SAFE_XFree

parent ebc2ea79
...@@ -304,8 +304,7 @@ Bool nxagentIsParentOf(Display *d, XlibWindow possible_parent, XlibWindow candid ...@@ -304,8 +304,7 @@ Bool nxagentIsParentOf(Display *d, XlibWindow possible_parent, XlibWindow candid
if (XQueryTree(d, candidate, &root, &parent, &children, &num_children)) if (XQueryTree(d, candidate, &root, &parent, &children, &num_children))
{ {
if (children) SAFE_XFree(children);
XFree((char *)children);
#ifdef TEST #ifdef TEST
fprintf(stderr, "%s: parent of full screen window [%p] root [%p] possible_parent [%p] candidate [%p]\n", __func__, parent, root, possible_parent, candidate); fprintf(stderr, "%s: parent of full screen window [%p] root [%p] possible_parent [%p] candidate [%p]\n", __func__, parent, root, possible_parent, candidate);
...@@ -490,11 +489,8 @@ Window nxagentCreateIconWindow(void) ...@@ -490,11 +489,8 @@ Window nxagentCreateIconWindow(void)
window_name, window_name, window_name, window_name,
NULL , 0 , sizeHints, wmHints, NULL); NULL , 0 , sizeHints, wmHints, NULL);
if (sizeHints) SAFE_XFree(sizeHints);
XFree(sizeHints); SAFE_XFree(wmHints);
if (wmHints)
XFree(wmHints);
/* /*
* Enable events from the icon window. * Enable events from the icon window.
...@@ -895,10 +891,9 @@ void freeDepths(DepthPtr depths, int num) ...@@ -895,10 +891,9 @@ void freeDepths(DepthPtr depths, int num)
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "%s: freeing depth [%d] index [%d] vids [%p]\n", __func__, depths[i].depth, i, (void*) depths[i].vids); fprintf(stderr, "%s: freeing depth [%d] index [%d] vids [%p]\n", __func__, depths[i].depth, i, (void*) depths[i].vids);
#endif #endif
free(depths[i].vids); SAFE_free(depths[i].vids);
depths[i].vids = NULL;
} }
free(depths); SAFE_free(depths);
} }
Bool nxagentOpenScreen(ScreenPtr pScreen, Bool nxagentOpenScreen(ScreenPtr pScreen,
...@@ -1393,7 +1388,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, ...@@ -1393,7 +1388,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
if (!pFrameBufferBits) if (!pFrameBufferBits)
{ {
freeDepths(depths, numDepths); freeDepths(depths, numDepths);
free(visuals); SAFE_free(visuals);
return FALSE; return FALSE;
} }
...@@ -1416,7 +1411,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, ...@@ -1416,7 +1411,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
monitorResolution, monitorResolution, PixmapBytePad(nxagentOption(RootWidth), rootDepth), bitsPerPixel)) monitorResolution, monitorResolution, PixmapBytePad(nxagentOption(RootWidth), rootDepth), bitsPerPixel))
{ {
freeDepths(depths, numDepths); freeDepths(depths, numDepths);
free(visuals); SAFE_free(visuals);
return FALSE; return FALSE;
} }
...@@ -1457,7 +1452,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, ...@@ -1457,7 +1452,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
pScreen -> numDepths = numDepths; pScreen -> numDepths = numDepths;
pScreen -> rootDepth = rootDepth; pScreen -> rootDepth = rootDepth;
free(pScreen -> visuals); SAFE_free(pScreen -> visuals);
pScreen -> visuals = visuals; pScreen -> visuals = visuals;
pScreen -> numVisuals = numVisuals; pScreen -> numVisuals = numVisuals;
pScreen -> rootVisual = defaultVisual; pScreen -> rootVisual = defaultVisual;
...@@ -1898,8 +1893,8 @@ N/A ...@@ -1898,8 +1893,8 @@ N/A
hint.res_class = strdup("NXAgent"); hint.res_class = strdup("NXAgent");
} }
XSetClassHint(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &hint); XSetClassHint(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &hint);
free(hint.res_name); SAFE_free(hint.res_name);
free(hint.res_class); SAFE_free(hint.res_class);
} }
if (nxagentOption(Fullscreen)) if (nxagentOption(Fullscreen))
...@@ -1983,17 +1978,8 @@ N/A ...@@ -1983,17 +1978,8 @@ N/A
nxagentWindowName, nxagentWindowName,
argv , argc , sizeHints, wmHints, NULL); argv , argc , sizeHints, wmHints, NULL);
if (sizeHints) SAFE_XFree(sizeHints);
{ SAFE_XFree(wmHints);
XFree(sizeHints);
sizeHints = NULL;
}
if (wmHints)
{
XFree(wmHints);
wmHints = NULL;
}
/* /*
* Clear the window but let it unmapped. We'll map it * Clear the window but let it unmapped. We'll map it
...@@ -2205,9 +2191,9 @@ Bool nxagentCloseScreen(ScreenPtr pScreen) ...@@ -2205,9 +2191,9 @@ Bool nxagentCloseScreen(ScreenPtr pScreen)
* Free the frame buffer. * Free the frame buffer.
*/ */
free(((PixmapPtr)pScreen -> devPrivate) -> devPrivate.ptr); SAFE_free(((PixmapPtr)pScreen -> devPrivate) -> devPrivate.ptr);
free(pScreen->devPrivate);pScreen->devPrivate = NULL; SAFE_free(pScreen->devPrivate);
free(pScreen->visuals); pScreen->visuals = NULL; SAFE_free(pScreen->visuals);
fbCloseScreen(pScreen); fbCloseScreen(pScreen);
...@@ -3167,7 +3153,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr ...@@ -3167,7 +3153,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr
length = nxagentImageLength(width, height, ZPixmap, 0, nxagentMasterDepth); length = nxagentImageLength(width, height, ZPixmap, 0, nxagentMasterDepth);
free(tBuffer); SAFE_free(tBuffer);
tBuffer = malloc(length); tBuffer = malloc(length);
...@@ -3224,7 +3210,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr ...@@ -3224,7 +3210,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr
RegionUnion(&nxagentShadowUpdateRegion, &nxagentShadowUpdateRegion, &updateRegion); RegionUnion(&nxagentShadowUpdateRegion, &nxagentShadowUpdateRegion, &updateRegion);
} }
free(tBuffer); SAFE_free(tBuffer);
RegionUninit(&updateRegion); RegionUninit(&updateRegion);
} }
...@@ -3442,7 +3428,7 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, ...@@ -3442,7 +3428,7 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height,
cBuffer = (unsigned char *) *buffer; cBuffer = (unsigned char *) *buffer;
*buffer = (char *) icBuffer; *buffer = (char *) icBuffer;
free(cBuffer); SAFE_free(cBuffer);
} }
#ifdef NXAGENT_ARTSD #ifdef NXAGENT_ARTSD
...@@ -3625,7 +3611,7 @@ FIXME: The port information is not used at the moment and produces a ...@@ -3625,7 +3611,7 @@ FIXME: The port information is not used at the moment and produces a
strlen(local_buf), local_buf, 1); strlen(local_buf), local_buf, 1);
} }
free(local_buf); SAFE_free(local_buf);
} }
} }
} }
...@@ -4049,7 +4035,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) ...@@ -4049,7 +4035,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
#endif #endif
number = 1; number = 1;
free(screeninfo); SAFE_free(screeninfo);
if (!(screeninfo = malloc(sizeof(XineramaScreenInfo)))) { if (!(screeninfo = malloc(sizeof(XineramaScreenInfo)))) {
return FALSE; return FALSE;
...@@ -4318,8 +4304,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) ...@@ -4318,8 +4304,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
} }
/* release allocated memory */ /* release allocated memory */
free(screeninfo); SAFE_free(screeninfo);
screeninfo = NULL;
#ifdef DEBUG #ifdef DEBUG
for (i = 0; i < pScrPriv->numCrtcs; i++) { for (i = 0; i < pScrPriv->numCrtcs; i++) {
...@@ -4434,7 +4419,7 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, ...@@ -4434,7 +4419,7 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg,
XSetClipRectangles(nxagentDisplay, gc, 0, 0, pRects, nRects, Unsorted); XSetClipRectangles(nxagentDisplay, gc, 0, 0, pRects, nRects, Unsorted);
free((char *) pRects); SAFE_free(pRects);
extents = *RegionExtents(&cleanRegion); extents = *RegionExtents(&cleanRegion);
...@@ -4580,7 +4565,7 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, ...@@ -4580,7 +4565,7 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg,
XSetClipRectangles(nxagentDisplay, gc, 0, 0, pRects, nRects, Unsorted); XSetClipRectangles(nxagentDisplay, gc, 0, 0, pRects, nRects, Unsorted);
free(pRects); SAFE_free(pRects);
extents = *RegionExtents(clipRegion); extents = *RegionExtents(clipRegion);
...@@ -4660,7 +4645,7 @@ void nxagentSetWMNormalHints(int screen, int width, int height) ...@@ -4660,7 +4645,7 @@ void nxagentSetWMNormalHints(int screen, int width, int height)
XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[screen], sizeHints); XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[screen], sizeHints);
XFree(sizeHints); SAFE_XFree(sizeHints);
} }
/* /*
...@@ -4679,7 +4664,7 @@ void nxagentSetWMNormalHintsMaxsize(ScreenPtr pScreen, int maxwidth, int maxheig ...@@ -4679,7 +4664,7 @@ void nxagentSetWMNormalHintsMaxsize(ScreenPtr pScreen, int maxwidth, int maxheig
sizeHints->max_height = maxheight; sizeHints->max_height = maxheight;
XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum],
sizeHints); sizeHints);
XFree(sizeHints); SAFE_XFree(sizeHints);
} }
} }
...@@ -4820,7 +4805,7 @@ FIXME ...@@ -4820,7 +4805,7 @@ FIXME
fprintf(stderr, "nxagentShowPixmap: XGetImage failed.\n"); fprintf(stderr, "nxagentShowPixmap: XGetImage failed.\n");
#endif #endif
free(data); SAFE_free(data);
return; return;
} }
...@@ -4853,7 +4838,7 @@ FIXME ...@@ -4853,7 +4838,7 @@ FIXME
XDestroyImage(image); XDestroyImage(image);
} }
free(data); SAFE_free(data);
/* /*
FIXME FIXME
...@@ -4905,7 +4890,7 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc, ...@@ -4905,7 +4890,7 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc,
fprintf(stderr, "nxagentFbRestoreArea: XGetImage failed.\n"); fprintf(stderr, "nxagentFbRestoreArea: XGetImage failed.\n");
#endif #endif
free(data); SAFE_free(data);
return; return;
} }
...@@ -4965,7 +4950,7 @@ FIXME ...@@ -4965,7 +4950,7 @@ FIXME
/* /*
FIXME FIXME
free(data); SAFE_free(data);
*/ */
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment