Commit 06d6db33 authored by Paul Eggert's avatar Paul Eggert
Browse files

* insdel.c (count_size_as_multibyte): Check for string overflow.

parent 2b4560a8
2011-05-16 Paul Eggert <eggert@cs.ucla.edu> 2011-05-16 Paul Eggert <eggert@cs.ucla.edu>
* insdel.c (count_size_as_multibyte): Check for string overflow.
* character.c (lisp_string_width): Check for string overflow. * character.c (lisp_string_width): Check for string overflow.
Use EMACS_INT, not int, for string indexes and lengths; in Use EMACS_INT, not int, for string indexes and lengths; in
particular, 2nd arg is now EMACS_INT, not int. Do not crash if particular, 2nd arg is now EMACS_INT, not int. Do not crash if
......
...@@ -20,6 +20,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -20,6 +20,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h> #include <config.h>
#include <setjmp.h> #include <setjmp.h>
#include <intprops.h>
#include "lisp.h" #include "lisp.h"
#include "intervals.h" #include "intervals.h"
#include "buffer.h" #include "buffer.h"
...@@ -581,14 +584,19 @@ count_size_as_multibyte (const unsigned char *ptr, EMACS_INT nbytes) ...@@ -581,14 +584,19 @@ count_size_as_multibyte (const unsigned char *ptr, EMACS_INT nbytes)
for (i = 0; i < nbytes; i++) for (i = 0; i < nbytes; i++)
{ {
unsigned int c = *ptr++; unsigned int c = *ptr++;
int n;
if (ASCII_CHAR_P (c)) if (ASCII_CHAR_P (c))
outgoing_nbytes++; n = 1;
else else
{ {
c = BYTE8_TO_CHAR (c); c = BYTE8_TO_CHAR (c);
outgoing_nbytes += CHAR_BYTES (c); n = CHAR_BYTES (c);
} }
if (INT_ADD_OVERFLOW (outgoing_nbytes, n))
string_overflow ();
outgoing_nbytes += n;
} }
return outgoing_nbytes; return outgoing_nbytes;
......
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