From: Alan Coopersmith Date: Sun, 3 May 2009 23:19:38 +0000 (-0700) Subject: Plug leaks of color conversion arrays in Do_Direct X-Git-Tag: submit/tizen/20130910.025321~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c2bbdd0e50510ffbb97e691c79fb9872eed39d4;p=platform%2Fupstream%2Fxwud.git Plug leaks of color conversion arrays in Do_Direct [This bug was found by the Parfait bug checking tool. For more information see http://research.sun.com/projects/parfait ] Change-Id: I753ab1fbb211966f9b5e45fa234fd53685233409 Signed-off-by: Alan Coopersmith --- diff --git a/xwud.c b/xwud.c index 1c83b7b..5ab8613 100644 --- a/xwud.c +++ b/xwud.c @@ -1026,6 +1026,8 @@ Do_Direct(Display *dpy, XWDFileHeader *header, Colormap *colormap, if (in_image->depth <= 12) { pix = 1 << in_image->depth; pixels = (unsigned long *)malloc(sizeof(unsigned long) * pix); + if (pixels == NULL) + Error("Unable to allocate memory for pixel conversion"); for (i = 0; i < pix; i++) pixels[i] = ~0L; color.flags = DoRed | DoGreen | DoBlue; @@ -1057,6 +1059,7 @@ Do_Direct(Display *dpy, XWDFileHeader *header, Colormap *colormap, XPutPixel(out_image, x, y, color.pixel); } } + free(pixels); } else if (header->visual_class == TrueColor && vinfo->class == TrueColor) { ormask = vinfo->red_mask; @@ -1092,6 +1095,8 @@ Do_Direct(Display *dpy, XWDFileHeader *header, Colormap *colormap, pix = 1 << 12; pixels = (unsigned long *)malloc(sizeof(unsigned long) * pix); rpixels = (unsigned long *)malloc(sizeof(unsigned long) * pix); + if ((pixels == NULL) || (rpixels == NULL)) + Error("Unable to allocate memory for pixel conversion"); for (i = 0; i < pix; i++) { pixels[i] = ~0L; rpixels[i] = ~0L; @@ -1128,6 +1133,8 @@ Do_Direct(Display *dpy, XWDFileHeader *header, Colormap *colormap, XPutPixel(out_image, x, y, color.pixel); } } + free(pixels); + free(rpixels); } }