aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/image.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/image.c b/src/image.c
index d9b7101d658..06a8154842c 100644
--- a/src/image.c
+++ b/src/image.c
@@ -3028,6 +3028,7 @@ enum xbm_keyword_index
3028 XBM_FILE, 3028 XBM_FILE,
3029 XBM_WIDTH, 3029 XBM_WIDTH,
3030 XBM_HEIGHT, 3030 XBM_HEIGHT,
3031 XBM_STRIDE,
3031 XBM_DATA, 3032 XBM_DATA,
3032 XBM_FOREGROUND, 3033 XBM_FOREGROUND,
3033 XBM_BACKGROUND, 3034 XBM_BACKGROUND,
@@ -3049,6 +3050,7 @@ static const struct image_keyword xbm_format[XBM_LAST] =
3049 {":file", IMAGE_STRING_VALUE, 0}, 3050 {":file", IMAGE_STRING_VALUE, 0},
3050 {":width", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 3051 {":width", IMAGE_POSITIVE_INTEGER_VALUE, 0},
3051 {":height", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 3052 {":height", IMAGE_POSITIVE_INTEGER_VALUE, 0},
3053 {":stride", IMAGE_POSITIVE_INTEGER_VALUE, 0},
3052 {":data", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 3054 {":data", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
3053 {":foreground", IMAGE_STRING_OR_NIL_VALUE, 0}, 3055 {":foreground", IMAGE_STRING_OR_NIL_VALUE, 0},
3054 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}, 3056 {":background", IMAGE_STRING_OR_NIL_VALUE, 0},
@@ -3124,7 +3126,7 @@ xbm_image_p (Lisp_Object object)
3124 else 3126 else
3125 { 3127 {
3126 Lisp_Object data; 3128 Lisp_Object data;
3127 int width, height; 3129 int width, height, stride;
3128 3130
3129 /* Entries for `:width', `:height' and `:data' must be present. */ 3131 /* Entries for `:width', `:height' and `:data' must be present. */
3130 if (!kw[XBM_WIDTH].count 3132 if (!kw[XBM_WIDTH].count
@@ -3136,6 +3138,11 @@ xbm_image_p (Lisp_Object object)
3136 width = XFIXNAT (kw[XBM_WIDTH].value); 3138 width = XFIXNAT (kw[XBM_WIDTH].value);
3137 height = XFIXNAT (kw[XBM_HEIGHT].value); 3139 height = XFIXNAT (kw[XBM_HEIGHT].value);
3138 3140
3141 if (!kw[XBM_STRIDE].count)
3142 stride = width;
3143 else
3144 stride = XFIXNAT (kw[XBM_STRIDE].value);
3145
3139 /* Check type of data, and width and height against contents of 3146 /* Check type of data, and width and height against contents of
3140 data. */ 3147 data. */
3141 if (VECTORP (data)) 3148 if (VECTORP (data))
@@ -3154,8 +3161,7 @@ xbm_image_p (Lisp_Object object)
3154 3161
3155 if (STRINGP (elt)) 3162 if (STRINGP (elt))
3156 { 3163 {
3157 if (SCHARS (elt) 3164 if (SCHARS (elt) < stride / CHAR_BIT)
3158 < (width + CHAR_BIT - 1) / CHAR_BIT)
3159 return 0; 3165 return 0;
3160 } 3166 }
3161 else if (BOOL_VECTOR_P (elt)) 3167 else if (BOOL_VECTOR_P (elt))
@@ -3169,13 +3175,16 @@ xbm_image_p (Lisp_Object object)
3169 } 3175 }
3170 else if (STRINGP (data)) 3176 else if (STRINGP (data))
3171 { 3177 {
3172 if (SCHARS (data) 3178 if (SCHARS (data) < stride / CHAR_BIT * height)
3173 < (width + CHAR_BIT - 1) / CHAR_BIT * height)
3174 return 0; 3179 return 0;
3175 } 3180 }
3176 else if (BOOL_VECTOR_P (data)) 3181 else if (BOOL_VECTOR_P (data))
3177 { 3182 {
3178 if (bool_vector_size (data) / height < width) 3183 if (height > 1 && stride != (width + CHAR_BIT - 1)
3184 / CHAR_BIT * CHAR_BIT)
3185 return 0;
3186
3187 if (bool_vector_size (data) / height < stride)
3179 return 0; 3188 return 0;
3180 } 3189 }
3181 else 3190 else