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:
committed by
Carlos R. Mafra
parent
8d09af51b8
commit
ba8cd2abe4
@@ -85,6 +85,9 @@ WMPixmap *WMCreatePixmapFromRImage(WMScreen * scrPtr, RImage * image, int thresh
|
||||
WMPixmap *pixPtr;
|
||||
Pixmap pixmap, mask;
|
||||
|
||||
if (image == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!RConvertImageMask(scrPtr->rcontext, image, &pixmap, &mask, threshold)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ RImage *RScaleImage(RImage * image, unsigned new_width, unsigned new_height)
|
||||
unsigned char *d;
|
||||
RImage *img;
|
||||
|
||||
if (image == NULL)
|
||||
return NULL;
|
||||
|
||||
if (new_width == image->width && new_height == image->height)
|
||||
return RCloneImage(image);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user