summaryrefslogtreecommitdiff
path: root/app/xwud/xwud.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2009-10-24 15:44:15 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2009-10-24 15:44:15 +0000
commit68898a77a47f13ebb3ec543d115b77ab9f604dd7 (patch)
treef0a9fc18f8e88b3c78d774e1617b6328deb61986 /app/xwud/xwud.c
parent64f81ec387ccd840d6a36768e61e3a17b329e17a (diff)
Update to xwud 1.0.2
Diffstat (limited to 'app/xwud/xwud.c')
-rw-r--r--app/xwud/xwud.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/xwud/xwud.c b/app/xwud/xwud.c
index 3e1e69336..5ab861359 100644
--- a/app/xwud/xwud.c
+++ b/app/xwud/xwud.c
@@ -42,11 +42,11 @@ from The Open Group.
#include <errno.h>
#include <stdlib.h>
-Atom wm_protocols;
-Atom wm_delete_window;
-int split;
+static Atom wm_protocols;
+static Atom wm_delete_window;
+static int split;
-char *progname;
+static char *progname;
static void usage(void);
static Bool Read(char *ptr, int size, int nitems, FILE *stream);
@@ -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);
}
}