aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2011-06-03 19:49:51 -0700
committerPaul Eggert2011-06-03 19:49:51 -0700
commitedaa182249601b0f7ee36f9863243b6919943982 (patch)
tree1e399289df34c433f0471efdfb8a6da4ab05ac25 /src/alloc.c
parentc6c3615fb23e438701da089110b645fc771f8087 (diff)
downloademacs-edaa182249601b0f7ee36f9863243b6919943982.tar.gz
emacs-edaa182249601b0f7ee36f9863243b6919943982.zip
Check for buffer and string overflow more precisely.
* buffer.h (BUF_BYTES_MAX): New macro. * lisp.h (STRING_BYTES_MAX): New macro. * alloc.c (Fmake_string): * character.c (string_escape_byte8): * coding.c (coding_alloc_by_realloc): * doprnt.c (doprnt): * editfns.c (Fformat): * eval.c (verror): Use STRING_BYTES_MAX, not MOST_POSITIVE_FIXNUM, since they may not be the same number. * editfns.c (Finsert_char): * fileio.c (Finsert_file_contents): Likewise for BUF_BYTES_MAX.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 0c18fca1755..d20ee1e59e3 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2205,7 +2205,7 @@ INIT must be an integer that represents a character. */)
2205 int len = CHAR_STRING (c, str); 2205 int len = CHAR_STRING (c, str);
2206 EMACS_INT string_len = XINT (length); 2206 EMACS_INT string_len = XINT (length);
2207 2207
2208 if (string_len > MOST_POSITIVE_FIXNUM / len) 2208 if (string_len > STRING_BYTES_MAX / len)
2209 string_overflow (); 2209 string_overflow ();
2210 nbytes = len * string_len; 2210 nbytes = len * string_len;
2211 val = make_uninit_multibyte_string (string_len, nbytes); 2211 val = make_uninit_multibyte_string (string_len, nbytes);