diff options
| author | Paul Eggert | 2011-06-21 23:16:16 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-21 23:16:16 -0700 |
| commit | 0766b489e1b34964bb43db221fe967d54ac5ec5e (patch) | |
| tree | 1de7cf403512dcf52d8d14dd3f05cc8065b8ad4a /src/image.c | |
| parent | 21514da7b21e248fa5046ab27834fa431a34204c (diff) | |
| download | emacs-0766b489e1b34964bb43db221fe967d54ac5ec5e.tar.gz emacs-0766b489e1b34964bb43db221fe967d54ac5ec5e.zip | |
* dispextern.h (struct face.stipple):
* image.c (x_bitmap_height, x_bitmap_width, x_bitmap_pixmap)
(x_bitmap_mask, x_allocate_bitmap_record)
(x_create_bitmap_from_data, x_create_bitmap_from_file)
(x_destroy_bitmap, x_destroy_all_bitmaps, x_create_bitmap_mask)
(x_create_bitmap_from_xpm_data):
* nsterm.h (struct ns_display_info.bitmaps_size, .bitmaps_last):
* w32term.h (struct w32_display_info.icon_bitmap_id, .bitmaps_size)
(.bitmaps_last):
* xfaces.c (load_pixmap):
* xterm.c (x_bitmap_icon, x_wm_set_icon_pixmap):
* xterm.h (struct x_display_info.icon_bitmap_id, .bitmaps_size)
(.bitmaps_last, struct x_output.icon_bitmap):
Use ptrdiff_t, not int, for bitmap indexes.
(x_allocate_bitmap_record): Check for size overflow.
* dispextern.h, lisp.h: Adjust to API changes elsewhere.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/image.c b/src/image.c index b5b93cb5b69..01cc95f7b38 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -182,20 +182,20 @@ XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel) | |||
| 182 | /* Functions to access the contents of a bitmap, given an id. */ | 182 | /* Functions to access the contents of a bitmap, given an id. */ |
| 183 | 183 | ||
| 184 | int | 184 | int |
| 185 | x_bitmap_height (FRAME_PTR f, int id) | 185 | x_bitmap_height (FRAME_PTR f, ptrdiff_t id) |
| 186 | { | 186 | { |
| 187 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].height; | 187 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].height; |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | int | 190 | int |
| 191 | x_bitmap_width (FRAME_PTR f, int id) | 191 | x_bitmap_width (FRAME_PTR f, ptrdiff_t id) |
| 192 | { | 192 | { |
| 193 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].width; | 193 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].width; |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) | 196 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) |
| 197 | int | 197 | int |
| 198 | x_bitmap_pixmap (FRAME_PTR f, int id) | 198 | x_bitmap_pixmap (FRAME_PTR f, ptrdiff_t id) |
| 199 | { | 199 | { |
| 200 | return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap; | 200 | return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap; |
| 201 | } | 201 | } |
| @@ -203,7 +203,7 @@ x_bitmap_pixmap (FRAME_PTR f, int id) | |||
| 203 | 203 | ||
| 204 | #ifdef HAVE_X_WINDOWS | 204 | #ifdef HAVE_X_WINDOWS |
| 205 | int | 205 | int |
| 206 | x_bitmap_mask (FRAME_PTR f, int id) | 206 | x_bitmap_mask (FRAME_PTR f, ptrdiff_t id) |
| 207 | { | 207 | { |
| 208 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].mask; | 208 | return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].mask; |
| 209 | } | 209 | } |
| @@ -211,11 +211,11 @@ x_bitmap_mask (FRAME_PTR f, int id) | |||
| 211 | 211 | ||
| 212 | /* Allocate a new bitmap record. Returns index of new record. */ | 212 | /* Allocate a new bitmap record. Returns index of new record. */ |
| 213 | 213 | ||
| 214 | static int | 214 | static ptrdiff_t |
| 215 | x_allocate_bitmap_record (FRAME_PTR f) | 215 | x_allocate_bitmap_record (FRAME_PTR f) |
| 216 | { | 216 | { |
| 217 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 217 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 218 | int i; | 218 | ptrdiff_t i; |
| 219 | 219 | ||
| 220 | if (dpyinfo->bitmaps == NULL) | 220 | if (dpyinfo->bitmaps == NULL) |
| 221 | { | 221 | { |
| @@ -233,6 +233,9 @@ x_allocate_bitmap_record (FRAME_PTR f) | |||
| 233 | if (dpyinfo->bitmaps[i].refcount == 0) | 233 | if (dpyinfo->bitmaps[i].refcount == 0) |
| 234 | return i + 1; | 234 | return i + 1; |
| 235 | 235 | ||
| 236 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Bitmap_Record) / 2 | ||
| 237 | < dpyinfo->bitmaps_size) | ||
| 238 | memory_full (SIZE_MAX); | ||
| 236 | dpyinfo->bitmaps_size *= 2; | 239 | dpyinfo->bitmaps_size *= 2; |
| 237 | dpyinfo->bitmaps | 240 | dpyinfo->bitmaps |
| 238 | = (Bitmap_Record *) xrealloc (dpyinfo->bitmaps, | 241 | = (Bitmap_Record *) xrealloc (dpyinfo->bitmaps, |
| @@ -250,11 +253,11 @@ x_reference_bitmap (FRAME_PTR f, int id) | |||
| 250 | 253 | ||
| 251 | /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */ | 254 | /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */ |
| 252 | 255 | ||
| 253 | int | 256 | ptrdiff_t |
| 254 | x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsigned int height) | 257 | x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsigned int height) |
| 255 | { | 258 | { |
| 256 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 259 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 257 | int id; | 260 | ptrdiff_t id; |
| 258 | 261 | ||
| 259 | #ifdef HAVE_X_WINDOWS | 262 | #ifdef HAVE_X_WINDOWS |
| 260 | Pixmap bitmap; | 263 | Pixmap bitmap; |
| @@ -309,7 +312,7 @@ x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsi | |||
| 309 | 312 | ||
| 310 | /* Create bitmap from file FILE for frame F. */ | 313 | /* Create bitmap from file FILE for frame F. */ |
| 311 | 314 | ||
| 312 | int | 315 | ptrdiff_t |
| 313 | x_create_bitmap_from_file (struct frame *f, Lisp_Object file) | 316 | x_create_bitmap_from_file (struct frame *f, Lisp_Object file) |
| 314 | { | 317 | { |
| 315 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 318 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| @@ -319,7 +322,7 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file) | |||
| 319 | #endif /* HAVE_NTGUI */ | 322 | #endif /* HAVE_NTGUI */ |
| 320 | 323 | ||
| 321 | #ifdef HAVE_NS | 324 | #ifdef HAVE_NS |
| 322 | int id; | 325 | ptrdiff_t id; |
| 323 | void *bitmap = ns_image_from_file (file); | 326 | void *bitmap = ns_image_from_file (file); |
| 324 | 327 | ||
| 325 | if (!bitmap) | 328 | if (!bitmap) |
| @@ -340,7 +343,8 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file) | |||
| 340 | #ifdef HAVE_X_WINDOWS | 343 | #ifdef HAVE_X_WINDOWS |
| 341 | unsigned int width, height; | 344 | unsigned int width, height; |
| 342 | Pixmap bitmap; | 345 | Pixmap bitmap; |
| 343 | int xhot, yhot, result, id; | 346 | int xhot, yhot, result; |
| 347 | ptrdiff_t id; | ||
| 344 | Lisp_Object found; | 348 | Lisp_Object found; |
| 345 | int fd; | 349 | int fd; |
| 346 | char *filename; | 350 | char *filename; |
| @@ -413,7 +417,7 @@ free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record *bm) | |||
| 413 | /* Remove reference to bitmap with id number ID. */ | 417 | /* Remove reference to bitmap with id number ID. */ |
| 414 | 418 | ||
| 415 | void | 419 | void |
| 416 | x_destroy_bitmap (FRAME_PTR f, int id) | 420 | x_destroy_bitmap (FRAME_PTR f, ptrdiff_t id) |
| 417 | { | 421 | { |
| 418 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 422 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 419 | 423 | ||
| @@ -435,7 +439,7 @@ x_destroy_bitmap (FRAME_PTR f, int id) | |||
| 435 | void | 439 | void |
| 436 | x_destroy_all_bitmaps (Display_Info *dpyinfo) | 440 | x_destroy_all_bitmaps (Display_Info *dpyinfo) |
| 437 | { | 441 | { |
| 438 | int i; | 442 | ptrdiff_t i; |
| 439 | Bitmap_Record *bm = dpyinfo->bitmaps; | 443 | Bitmap_Record *bm = dpyinfo->bitmaps; |
| 440 | 444 | ||
| 441 | for (i = 0; i < dpyinfo->bitmaps_last; i++, bm++) | 445 | for (i = 0; i < dpyinfo->bitmaps_last; i++, bm++) |
| @@ -467,7 +471,7 @@ static void x_destroy_x_image (XImagePtr ximg); | |||
| 467 | It's nicer with some borders in this context */ | 471 | It's nicer with some borders in this context */ |
| 468 | 472 | ||
| 469 | int | 473 | int |
| 470 | x_create_bitmap_mask (struct frame *f, int id) | 474 | x_create_bitmap_mask (struct frame *f, ptrdiff_t id) |
| 471 | { | 475 | { |
| 472 | Pixmap pixmap, mask; | 476 | Pixmap pixmap, mask; |
| 473 | XImagePtr ximg, mask_img; | 477 | XImagePtr ximg, mask_img; |
| @@ -3281,11 +3285,12 @@ xpm_image_p (Lisp_Object object) | |||
| 3281 | #endif /* HAVE_XPM || HAVE_NS */ | 3285 | #endif /* HAVE_XPM || HAVE_NS */ |
| 3282 | 3286 | ||
| 3283 | #if defined HAVE_XPM && defined HAVE_X_WINDOWS && !defined USE_GTK | 3287 | #if defined HAVE_XPM && defined HAVE_X_WINDOWS && !defined USE_GTK |
| 3284 | int | 3288 | ptrdiff_t |
| 3285 | x_create_bitmap_from_xpm_data (struct frame *f, const char **bits) | 3289 | x_create_bitmap_from_xpm_data (struct frame *f, const char **bits) |
| 3286 | { | 3290 | { |
| 3287 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 3291 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 3288 | int id, rc; | 3292 | ptrdiff_t id; |
| 3293 | int rc; | ||
| 3289 | XpmAttributes attrs; | 3294 | XpmAttributes attrs; |
| 3290 | Pixmap bitmap, mask; | 3295 | Pixmap bitmap, mask; |
| 3291 | 3296 | ||