2011-06-16 Paul Eggert <eggert@cs.ucla.edu>
+ * insdel.c (replace_range): Fix buf overflow when insbytes < outgoing.
+
* insdel.c, lisp.h (buffer_overflow): New function.
(insert_from_buffer_1, replace_range, replace_range_2):
* insdel.c (make_gap_larger):
= count_size_as_multibyte (SDATA (new), insbytes);
/* Make sure point-max won't overflow after this insertion. */
- XSETINT (temp, Z_BYTE - nbytes_del + insbytes);
- if (Z_BYTE - nbytes_del + insbytes != XINT (temp))
+ XSETINT (temp, Z_BYTE - nbytes_del + outgoing_insbytes);
+ if (Z_BYTE - nbytes_del + outgoing_insbytes != XINT (temp))
buffer_overflow ();
GCPRO1 (new);
if (Z - GPT < END_UNCHANGED)
END_UNCHANGED = Z - GPT;
- if (GAP_SIZE < insbytes)
- make_gap (insbytes - GAP_SIZE);
+ if (GAP_SIZE < outgoing_insbytes)
+ make_gap (outgoing_insbytes - GAP_SIZE);
/* Copy the string text into the buffer, perhaps converting
between single-byte and multibyte. */