summaryrefslogtreecommitdiff
path: root/src/image.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-06-21 23:16:16 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-06-21 23:16:16 -0700
commit0766b489e1b34964bb43db221fe967d54ac5ec5e (patch)
tree1de7cf403512dcf52d8d14dd3f05cc8065b8ad4a /src/image.c
parent21514da7b21e248fa5046ab27834fa431a34204c (diff)
downloademacs-0766b489e1b34964bb43db221fe967d54ac5ec5e.tar.gz
* 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.c37
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)
/* Functions to access the contents of a bitmap, given an id. */
int
-x_bitmap_height (FRAME_PTR f, int id)
+x_bitmap_height (FRAME_PTR f, ptrdiff_t id)
{
return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].height;
}
int
-x_bitmap_width (FRAME_PTR f, int id)
+x_bitmap_width (FRAME_PTR f, ptrdiff_t id)
{
return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].width;
}
#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
int
-x_bitmap_pixmap (FRAME_PTR f, int id)
+x_bitmap_pixmap (FRAME_PTR f, ptrdiff_t id)
{
return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap;
}
@@ -203,7 +203,7 @@ x_bitmap_pixmap (FRAME_PTR f, int id)
#ifdef HAVE_X_WINDOWS
int
-x_bitmap_mask (FRAME_PTR f, int id)
+x_bitmap_mask (FRAME_PTR f, ptrdiff_t id)
{
return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].mask;
}
@@ -211,11 +211,11 @@ x_bitmap_mask (FRAME_PTR f, int id)
/* Allocate a new bitmap record. Returns index of new record. */
-static int
+static ptrdiff_t
x_allocate_bitmap_record (FRAME_PTR f)
{
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
- int i;
+ ptrdiff_t i;
if (dpyinfo->bitmaps == NULL)
{
@@ -233,6 +233,9 @@ x_allocate_bitmap_record (FRAME_PTR f)
if (dpyinfo->bitmaps[i].refcount == 0)
return i + 1;
+ if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Bitmap_Record) / 2
+ < dpyinfo->bitmaps_size)
+ memory_full (SIZE_MAX);
dpyinfo->bitmaps_size *= 2;
dpyinfo->bitmaps
= (Bitmap_Record *) xrealloc (dpyinfo->bitmaps,
@@ -250,11 +253,11 @@ x_reference_bitmap (FRAME_PTR f, int id)
/* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */
-int
+ptrdiff_t
x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsigned int height)
{
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
- int id;
+ ptrdiff_t id;
#ifdef HAVE_X_WINDOWS
Pixmap bitmap;
@@ -309,7 +312,7 @@ x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsi
/* Create bitmap from file FILE for frame F. */
-int
+ptrdiff_t
x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
{
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
@@ -319,7 +322,7 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
#endif /* HAVE_NTGUI */
#ifdef HAVE_NS
- int id;
+ ptrdiff_t id;
void *bitmap = ns_image_from_file (file);
if (!bitmap)
@@ -340,7 +343,8 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
#ifdef HAVE_X_WINDOWS
unsigned int width, height;
Pixmap bitmap;
- int xhot, yhot, result, id;
+ int xhot, yhot, result;
+ ptrdiff_t id;
Lisp_Object found;
int fd;
char *filename;
@@ -413,7 +417,7 @@ free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record *bm)
/* Remove reference to bitmap with id number ID. */
void
-x_destroy_bitmap (FRAME_PTR f, int id)
+x_destroy_bitmap (FRAME_PTR f, ptrdiff_t id)
{
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
@@ -435,7 +439,7 @@ x_destroy_bitmap (FRAME_PTR f, int id)
void
x_destroy_all_bitmaps (Display_Info *dpyinfo)
{
- int i;
+ ptrdiff_t i;
Bitmap_Record *bm = dpyinfo->bitmaps;
for (i = 0; i < dpyinfo->bitmaps_last; i++, bm++)
@@ -467,7 +471,7 @@ static void x_destroy_x_image (XImagePtr ximg);
It's nicer with some borders in this context */
int
-x_create_bitmap_mask (struct frame *f, int id)
+x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
{
Pixmap pixmap, mask;
XImagePtr ximg, mask_img;
@@ -3281,11 +3285,12 @@ xpm_image_p (Lisp_Object object)
#endif /* HAVE_XPM || HAVE_NS */
#if defined HAVE_XPM && defined HAVE_X_WINDOWS && !defined USE_GTK
-int
+ptrdiff_t
x_create_bitmap_from_xpm_data (struct frame *f, const char **bits)
{
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
- int id, rc;
+ ptrdiff_t id;
+ int rc;
XpmAttributes attrs;
Pixmap bitmap, mask;