From: Paul Eggert Date: Sat, 4 Jan 2020 21:33:44 +0000 (-0800) Subject: Fix bug in recent allocate_string_data patch X-Git-Tag: emacs-28.0.90~7908^2~177 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=add2b2da72babbc72134775499e14fc65da9bd44;p=emacs.git Fix bug in recent allocate_string_data patch Reported by Glenn Morris in: https://lists.gnu.org/r/emacs-devel/2020-01/msg00098.html * src/alloc.c (allocate_string_data): If the string is small and there is not enough room in the current block, clear the string if CLEARIT. --- diff --git a/src/alloc.c b/src/alloc.c index d6d456a8fc0..7eb37bb12da 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1831,26 +1831,27 @@ allocate_string_data (struct Lisp_String *s, b->next_free = data; large_sblocks = b; } - else if (current_sblock == NULL - || (((char *) current_sblock + SBLOCK_SIZE - - (char *) current_sblock->next_free) - < (needed + GC_STRING_EXTRA))) - { - /* Not enough room in the current sblock. */ - b = lisp_malloc (SBLOCK_SIZE, false, MEM_TYPE_NON_LISP); - data = b->data; - b->next = NULL; - b->next_free = data; - - if (current_sblock) - current_sblock->next = b; - else - oldest_sblock = b; - current_sblock = b; - } else { b = current_sblock; + + if (b == NULL + || (SBLOCK_SIZE - GC_STRING_EXTRA + < (char *) b->next_free - (char *) b + needed)) + { + /* Not enough room in the current sblock. */ + b = lisp_malloc (SBLOCK_SIZE, false, MEM_TYPE_NON_LISP); + data = b->data; + b->next = NULL; + b->next_free = data; + + if (current_sblock) + current_sblock->next = b; + else + oldest_sblock = b; + current_sblock = b; + } + data = b->next_free; if (clearit) memset (SDATA_DATA (data), 0, nbytes);