summaryrefslogtreecommitdiff
path: root/src/xpm_w32.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2012-02-05 00:48:00 +0100
committerBram Moolenaar <Bram@vim.org>2012-02-05 00:48:00 +0100
commite37c611012a8b0b822e9d60baacd642c20c07851 (patch)
treea076bdcd464ce8faecd75b8608d0a8737d258e62 /src/xpm_w32.c
parenta489e1d9d638604643f3ac70542f03227a39f7ef (diff)
downloadvim-git-e37c611012a8b0b822e9d60baacd642c20c07851.tar.gz
updated for version 7.3.428v7.3.428
Problem: Win32: an xpm file without a mask crashes Vim. Solution: Fail when the mask is missing. (Dave Bodenstab)
Diffstat (limited to 'src/xpm_w32.c')
-rw-r--r--src/xpm_w32.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/xpm_w32.c b/src/xpm_w32.c
index 45765e1f1..2ec32ed9f 100644
--- a/src/xpm_w32.c
+++ b/src/xpm_w32.c
@@ -1,4 +1,5 @@
-/*
+/* vi:set ts=8 sts=4 sw=4:
+ *
* Load XPM image.
*
* This function is placed in separate file because Xpm headers conflict with
@@ -30,9 +31,10 @@
#include "xpm.h"
/*
- * Tries to load Xpm image from file 'filename'.
- * If fails return -1.
- * success - 0 and image and mask BITMAPS
+ * Tries to load an Xpm image from the file "filename".
+ * Returns -1 on failure.
+ * Returns 0 on success and stores image and mask BITMAPS in "hImage" and
+ * "hShape".
*/
int
LoadXpmImage(filename, hImage, hShape)
@@ -40,7 +42,7 @@ LoadXpmImage(filename, hImage, hShape)
HBITMAP *hImage;
HBITMAP *hShape;
{
- XImage *img; /* loaded image */
+ XImage *img; /* loaded image */
XImage *shp; /* shapeimage */
XpmAttributes attr;
int res;
@@ -51,10 +53,13 @@ LoadXpmImage(filename, hImage, hShape)
DeleteDC(hdc);
if (res < 0)
return -1;
- else
+ if (shp == NULL)
{
- *hImage = img->bitmap;
- *hShape = shp->bitmap;
- return 0;
+ if (img)
+ XDestroyImage(img);
+ return -1;
}
+ *hImage = img->bitmap;
+ *hShape = shp->bitmap;
+ return 0;
}