diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-05-03 16:19:38 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-05-03 16:19:38 -0700 |
commit | a619bad7e2782594e608d1b1c890a2ef46e59659 (patch) | |
tree | 15f981629f39a20e3835b7a3cfe7a2247ff9fee1 | |
parent | 5a9ab7d199e399872bd197c6b2de59f52e197efd (diff) |
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 ]
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
-rw-r--r-- | xwud.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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); } } |