diff options
author | Chong Yidong <cyd@stupidchicken.com> | 2010-05-18 14:01:10 -0400 |
---|---|---|
committer | Chong Yidong <cyd@stupidchicken.com> | 2010-05-18 14:01:10 -0400 |
commit | 754790b6c5a0ebe9cc1f2463d9446c5cb19b4264 (patch) | |
tree | 9a013184548245cf9c4dac6b77db81d927d2d6bd /src/character.c | |
parent | dc9ed7949681bcb29cf151c5183efcc50260fa00 (diff) | |
download | emacs-754790b6c5a0ebe9cc1f2463d9446c5cb19b4264.tar.gz emacs-754790b6c5a0ebe9cc1f2463d9446c5cb19b4264.tar.bz2 emacs-754790b6c5a0ebe9cc1f2463d9446c5cb19b4264.zip |
* character.c (Fstring, Funibyte_string): Use SAFE_ALLOCA to
prevent stack overflow if number of arguments is too large
(Bug#6214).
Diffstat (limited to 'src/character.c')
-rw-r--r-- | src/character.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/character.c b/src/character.c index 5912a70d0ce..7cd1eedcef4 100644 --- a/src/character.c +++ b/src/character.c @@ -961,10 +961,13 @@ usage: (string &rest CHARACTERS) */) int n; Lisp_Object *args; { - int i; - unsigned char *buf = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH * n); - unsigned char *p = buf; - int c; + int i, c; + unsigned char *buf, *p; + Lisp_Object str; + USE_SAFE_ALLOCA; + + SAFE_ALLOCA (buf, unsigned char *, MAX_MULTIBYTE_LENGTH * n); + p = buf; for (i = 0; i < n; i++) { @@ -973,7 +976,9 @@ usage: (string &rest CHARACTERS) */) p += CHAR_STRING (c, p); } - return make_string_from_bytes ((char *) buf, n, p - buf); + str = make_string_from_bytes ((char *) buf, n, p - buf); + SAFE_FREE (); + return str; } DEFUN ("unibyte-string", Funibyte_string, Sunibyte_string, 0, MANY, 0, @@ -983,10 +988,13 @@ usage: (unibyte-string &rest BYTES) */) int n; Lisp_Object *args; { - int i; - unsigned char *buf = (unsigned char *) alloca (n); - unsigned char *p = buf; - unsigned c; + int i, c; + unsigned char *buf, *p; + Lisp_Object str; + USE_SAFE_ALLOCA; + + SAFE_ALLOCA (buf, unsigned char *, n); + p = buf; for (i = 0; i < n; i++) { @@ -997,7 +1005,9 @@ usage: (unibyte-string &rest BYTES) */) *p++ = c; } - return make_string_from_bytes ((char *) buf, n, p - buf); + str = make_string_from_bytes ((char *) buf, n, p - buf); + SAFE_FREE (); + return str; } DEFUN ("char-resolve-modifiers", Fchar_resolve_modifiers, |