mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-28 07:45:00 +00:00
Fix stack overflow in string creation (Bug#6214).
* character.c (Fstring, Funibyte_string): Use SAFE_ALLOCA to prevent stack overflow if number of arguments is too large (Bug#6214).
This commit is contained in:
commit
60dd06a082
@ -1,3 +1,9 @@
|
|||||||
|
2010-05-18 Chong Yidong <cyd@stupidchicken.com>
|
||||||
|
|
||||||
|
* character.c (Fstring, Funibyte_string): Use SAFE_ALLOCA to
|
||||||
|
prevent stack overflow if number of arguments is too large
|
||||||
|
(Bug#6214).
|
||||||
|
|
||||||
2010-05-18 Juanma Barranquero <lekktu@gmail.com>
|
2010-05-18 Juanma Barranquero <lekktu@gmail.com>
|
||||||
|
|
||||||
* charset.c (load_charset_map_from_file): Don't call close after fclose.
|
* charset.c (load_charset_map_from_file): Don't call close after fclose.
|
||||||
|
@ -961,10 +961,13 @@ usage: (string &rest CHARACTERS) */)
|
|||||||
int n;
|
int n;
|
||||||
Lisp_Object *args;
|
Lisp_Object *args;
|
||||||
{
|
{
|
||||||
int i;
|
int i, c;
|
||||||
unsigned char *buf = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH * n);
|
unsigned char *buf, *p;
|
||||||
unsigned char *p = buf;
|
Lisp_Object str;
|
||||||
int c;
|
USE_SAFE_ALLOCA;
|
||||||
|
|
||||||
|
SAFE_ALLOCA (buf, unsigned char *, MAX_MULTIBYTE_LENGTH * n);
|
||||||
|
p = buf;
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@ -973,7 +976,9 @@ usage: (string &rest CHARACTERS) */)
|
|||||||
p += CHAR_STRING (c, p);
|
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,
|
DEFUN ("unibyte-string", Funibyte_string, Sunibyte_string, 0, MANY, 0,
|
||||||
@ -983,10 +988,13 @@ usage: (unibyte-string &rest BYTES) */)
|
|||||||
int n;
|
int n;
|
||||||
Lisp_Object *args;
|
Lisp_Object *args;
|
||||||
{
|
{
|
||||||
int i;
|
int i, c;
|
||||||
unsigned char *buf = (unsigned char *) alloca (n);
|
unsigned char *buf, *p;
|
||||||
unsigned char *p = buf;
|
Lisp_Object str;
|
||||||
unsigned c;
|
USE_SAFE_ALLOCA;
|
||||||
|
|
||||||
|
SAFE_ALLOCA (buf, unsigned char *, n);
|
||||||
|
p = buf;
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@ -997,7 +1005,9 @@ usage: (unibyte-string &rest BYTES) */)
|
|||||||
*p++ = c;
|
*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,
|
DEFUN ("char-resolve-modifiers", Fchar_resolve_modifiers,
|
||||||
|
Loading…
Reference in New Issue
Block a user