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 <[email protected]> --- WINGs/wpixmap.c | 3 +++ wrlib/scale.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/WINGs/wpixmap.c b/WINGs/wpixmap.c index 272e56a..5ad311c 100644 --- a/WINGs/wpixmap.c +++ b/WINGs/wpixmap.c @@ -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; } diff --git a/wrlib/scale.c b/wrlib/scale.c index 0f5952c..9461233 100644 --- a/wrlib/scale.c +++ b/wrlib/scale.c @@ -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); -- 2.1.4 -- To unsubscribe, send mail to [email protected].
