aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov2012-07-17 16:31:29 +0400
committerDmitry Antipov2012-07-17 16:31:29 +0400
commitb7ffe0402bda8231943066a1ce34e60b3dfdb6e7 (patch)
treed62c4b1b56613f5a7144346d99378dfb8c19c280 /src/alloc.c
parent4dc7c8d5795458e89d19b59f64760e155c2cd70b (diff)
downloademacs-b7ffe0402bda8231943066a1ce34e60b3dfdb6e7.tar.gz
emacs-b7ffe0402bda8231943066a1ce34e60b3dfdb6e7.zip
Restore old code in allocate_string_data to avoid Faset breakage.
Reported by Julien Danjou <julien@danjou.info> in http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00371.html. * alloc.c (allocate_string_data): Restore old code with minor adjustments, fix comment to explain this subtle issue.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 67ff3459e71..f8456e3645f 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1971,9 +1971,9 @@ void
1971allocate_string_data (struct Lisp_String *s, 1971allocate_string_data (struct Lisp_String *s,
1972 EMACS_INT nchars, EMACS_INT nbytes) 1972 EMACS_INT nchars, EMACS_INT nbytes)
1973{ 1973{
1974 struct sdata *data; 1974 struct sdata *data, *old_data;
1975 struct sblock *b; 1975 struct sblock *b;
1976 ptrdiff_t needed; 1976 ptrdiff_t needed, old_nbytes;
1977 1977
1978 if (STRING_BYTES_MAX < nbytes) 1978 if (STRING_BYTES_MAX < nbytes)
1979 string_overflow (); 1979 string_overflow ();
@@ -1981,6 +1981,13 @@ allocate_string_data (struct Lisp_String *s,
1981 /* Determine the number of bytes needed to store NBYTES bytes 1981 /* Determine the number of bytes needed to store NBYTES bytes
1982 of string data. */ 1982 of string data. */
1983 needed = SDATA_SIZE (nbytes); 1983 needed = SDATA_SIZE (nbytes);
1984 if (s->data)
1985 {
1986 old_data = SDATA_OF_STRING (s);
1987 old_nbytes = GC_STRING_BYTES (s);
1988 }
1989 else
1990 old_data = NULL;
1984 1991
1985 MALLOC_BLOCK_INPUT; 1992 MALLOC_BLOCK_INPUT;
1986 1993
@@ -2050,6 +2057,16 @@ allocate_string_data (struct Lisp_String *s,
2050 memcpy ((char *) data + needed, string_overrun_cookie, 2057 memcpy ((char *) data + needed, string_overrun_cookie,
2051 GC_STRING_OVERRUN_COOKIE_SIZE); 2058 GC_STRING_OVERRUN_COOKIE_SIZE);
2052#endif 2059#endif
2060
2061 /* Note that Faset may call to this function when S has already data
2062 assigned. In this case, mark data as free by setting it's string
2063 back-pointer to null, and record the size of the data in it. */
2064 if (old_data)
2065 {
2066 SDATA_NBYTES (old_data) = old_nbytes;
2067 old_data->string = NULL;
2068 }
2069
2053 consing_since_gc += needed; 2070 consing_since_gc += needed;
2054} 2071}
2055 2072