Skip to content

Commit add2b2d

Browse files
committed
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.
1 parent 9bbf175 commit add2b2d

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/alloc.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,26 +1831,27 @@ allocate_string_data (struct Lisp_String *s,
18311831
b->next_free = data;
18321832
large_sblocks = b;
18331833
}
1834-
else if (current_sblock == NULL
1835-
|| (((char *) current_sblock + SBLOCK_SIZE
1836-
- (char *) current_sblock->next_free)
1837-
< (needed + GC_STRING_EXTRA)))
1838-
{
1839-
/* Not enough room in the current sblock. */
1840-
b = lisp_malloc (SBLOCK_SIZE, false, MEM_TYPE_NON_LISP);
1841-
data = b->data;
1842-
b->next = NULL;
1843-
b->next_free = data;
1844-
1845-
if (current_sblock)
1846-
current_sblock->next = b;
1847-
else
1848-
oldest_sblock = b;
1849-
current_sblock = b;
1850-
}
18511834
else
18521835
{
18531836
b = current_sblock;
1837+
1838+
if (b == NULL
1839+
|| (SBLOCK_SIZE - GC_STRING_EXTRA
1840+
< (char *) b->next_free - (char *) b + needed))
1841+
{
1842+
/* Not enough room in the current sblock. */
1843+
b = lisp_malloc (SBLOCK_SIZE, false, MEM_TYPE_NON_LISP);
1844+
data = b->data;
1845+
b->next = NULL;
1846+
b->next_free = data;
1847+
1848+
if (current_sblock)
1849+
current_sblock->next = b;
1850+
else
1851+
oldest_sblock = b;
1852+
current_sblock = b;
1853+
}
1854+
18541855
data = b->next_free;
18551856
if (clearit)
18561857
memset (SDATA_DATA (data), 0, nbytes);

0 commit comments

Comments
 (0)