1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 20:10:29 +01:00

wrlib: return NULL if XImage could not be taken, for consistency

To be consistent with RCreateXImage and because it should not be up to the
caller to handle this, when XGetImage returns a NULL pointer then the
function RGetXImage will also return NULL instead of an RXImage structure
with a NULL pointer.

This consistent behaviour helps fixing a memory leak in WMaker reported by
Coverity (#50125).

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-06-14 19:34:05 +02:00
committed by Carlos R. Mafra
parent ad07a97788
commit 6c3cd08dad
2 changed files with 7 additions and 5 deletions

View File

@@ -390,10 +390,8 @@ static void showWorkspaceName(WScreen * scr, int workspace)
}
ximg = RGetXImage(scr->rcontext, scr->root_win, px, py, data->text->width, data->text->height);
if (!ximg || !ximg->image) {
if (!ximg)
goto erro;
}
XMapRaised(dpy, scr->workspace_name);
XFlush(dpy);

View File

@@ -207,7 +207,6 @@ RXImage *RGetXImage(RContext * context, Drawable d, int x, int y, unsigned width
ximg->is_shared = 0;
ximg->image = XGetImage(context->dpy, d, x, y, width, height, AllPlanes, ZPixmap);
}
return ximg;
#else /* !USE_XSHM */
ximg = malloc(sizeof(RXImage));
if (!ximg) {
@@ -216,9 +215,14 @@ RXImage *RGetXImage(RContext * context, Drawable d, int x, int y, unsigned width
}
ximg->image = XGetImage(context->dpy, d, x, y, width, height, AllPlanes, ZPixmap);
#endif /* !USE_XSHM */
if (ximg->image == NULL) {
free(ximg);
return NULL;
}
return ximg;
#endif /* !USE_XSHM */
}
void