2011-07-07 Paul Eggert <eggert@cs.ucla.edu>
+ * xselect.c: Integer signedness and overflow fixes.
+ (Fx_register_dnd_atom, x_handle_dnd_message):
+ Use ptrdiff_t, not size_t, since we prefer signed.
+ (Fx_register_dnd_atom): Check for ptrdiff_t (and size_t) overflow.
+ * xterm.h (struct x_display_info): Use ptrdiff_t, not size_t, for
+ x_dnd_atoms_size and x_dnd_atoms_length.
+
* doprnt.c: Prefer signed to unsigned when either works.
* eval.c (verror):
* doprnt.c (doprnt):
{
Atom x_atom;
struct frame *f = check_x_frame (frame);
- size_t i;
+ ptrdiff_t i;
struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
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_size *= 2;
dpyinfo->x_dnd_atoms = xrealloc (dpyinfo->x_dnd_atoms,
sizeof (*dpyinfo->x_dnd_atoms)
int x, y;
unsigned char *data = (unsigned char *) event->data.b;
int idata[5];
- size_t i;
+ ptrdiff_t i;
for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i)
if (dpyinfo->x_dnd_atoms[i] == event->message_type) break;
/* Atoms that are drag and drop atoms */
Atom *x_dnd_atoms;
- size_t x_dnd_atoms_size;
- size_t x_dnd_atoms_length;
+ ptrdiff_t x_dnd_atoms_size;
+ ptrdiff_t x_dnd_atoms_length;
/* Extended window manager hints, Atoms supported by the window manager and
atoms for settig the window type. */