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

Handle NULL pointer as good as possible (Coverity #50099)

As pointed by Coverity, in the "Configuration" panel of WPrefs there are
some images loaded, but if the images cannot be loaded correctly then the
returned NULL pointer can crash the application as it is dereferenced in
further function calls.

To solve this case, this patch is adding a NULL pointer check in the
functions RScaleImage (wrlib) and WMCreatePixmapFromRImage (WINGs), so both
can accept that NULL pointer to also return NULL, which means the existing
check for "icon == NULL" in the WPrefs code will be useful.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2015-04-25 12:44:21 +02:00
committed by Carlos R. Mafra
parent 8d09af51b8
commit ba8cd2abe4
2 changed files with 6 additions and 0 deletions

View File

@@ -85,6 +85,9 @@ WMPixmap *WMCreatePixmapFromRImage(WMScreen * scrPtr, RImage * image, int thresh
WMPixmap *pixPtr; WMPixmap *pixPtr;
Pixmap pixmap, mask; Pixmap pixmap, mask;
if (image == NULL)
return NULL;
if (!RConvertImageMask(scrPtr->rcontext, image, &pixmap, &mask, threshold)) { if (!RConvertImageMask(scrPtr->rcontext, image, &pixmap, &mask, threshold)) {
return NULL; return NULL;
} }

View File

@@ -52,6 +52,9 @@ RImage *RScaleImage(RImage * image, unsigned new_width, unsigned new_height)
unsigned char *d; unsigned char *d;
RImage *img; RImage *img;
if (image == NULL)
return NULL;
if (new_width == image->width && new_height == image->height) if (new_width == image->width && new_height == image->height)
return RCloneImage(image); return RCloneImage(image);