Commit a69fbedb authored by Paul Eggert's avatar Paul Eggert
Browse files

Simplify previous changes.

* image.c (x_allocate_bitmap_record, cache_image):
* xselect.c (Fx_register_dnd_atom):
Simplify previous changes by using xpalloc.
parent 3f74064e
2011-08-15 Paul Eggert <eggert@cs.ucla.edu>
2011-08-16 Paul Eggert <eggert@cs.ucla.edu>
Integer and memory overflow issues (Bug#9196).
* image.c (x_allocate_bitmap_record, cache_image):
* xselect.c (Fx_register_dnd_atom):
Simplify previous changes by using xpalloc.
* buffer.c (overlay_str_len): Now ptrdiff_t, not EMACS_INT,
since either will do and ptrdiff_t is convenient with xpalloc.
......
......@@ -216,15 +216,6 @@ x_allocate_bitmap_record (FRAME_PTR f)
Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
ptrdiff_t i;
if (dpyinfo->bitmaps == NULL)
{
dpyinfo->bitmaps
= (Bitmap_Record *) xmalloc (10 * sizeof (Bitmap_Record));
dpyinfo->bitmaps_size = 10;
dpyinfo->bitmaps_last = 1;
return 1;
}
if (dpyinfo->bitmaps_last < dpyinfo->bitmaps_size)
return ++dpyinfo->bitmaps_last;
......@@ -232,14 +223,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
= (Bitmap_Record *) xrealloc (dpyinfo->bitmaps,
(dpyinfo->bitmaps_size
* (2 * sizeof (Bitmap_Record))));
dpyinfo->bitmaps_size *= 2;
dpyinfo->bitmaps =
xpalloc (dpyinfo->bitmaps, &dpyinfo->bitmaps_size,
10, -1, sizeof *dpyinfo->bitmaps);
return ++dpyinfo->bitmaps_last;
}
......@@ -1836,14 +1822,7 @@ cache_image (struct frame *f, struct image *img)
/* If no free slot found, maybe enlarge c->images. */
if (i == c->used && c->used == c->size)
{
if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *c->images / 2 < c->size)
memory_full (SIZE_MAX);
c->images =
(struct image **) xrealloc (c->images,
c->size * (2 * sizeof *c->images));
c->size *= 2;
}
c->images = xpalloc (c->images, &c->size, 1, -1, sizeof *c->images);
/* Add IMG to c->images, and assign IMG an id. */
c->images[i] = img;
......
......@@ -2461,15 +2461,9 @@ FRAME is on. If FRAME is nil, the selected frame is used. */)
return Qnil;
if (dpyinfo->x_dnd_atoms_length == dpyinfo->x_dnd_atoms_size)
{
if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *dpyinfo->x_dnd_atoms / 2
< dpyinfo->x_dnd_atoms_size)
memory_full (SIZE_MAX);
dpyinfo->x_dnd_atoms = xrealloc (dpyinfo->x_dnd_atoms,
(2 * sizeof *dpyinfo->x_dnd_atoms
* dpyinfo->x_dnd_atoms_size));
dpyinfo->x_dnd_atoms_size *= 2;
}
dpyinfo->x_dnd_atoms =
xpalloc (dpyinfo->x_dnd_atoms, &dpyinfo->x_dnd_atoms_size,
1, -1, sizeof *dpyinfo->x_dnd_atoms);
dpyinfo->x_dnd_atoms[dpyinfo->x_dnd_atoms_length++] = x_atom;
return Qnil;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment