diff options
| author | Paul Eggert | 2020-01-04 13:33:44 -0800 |
|---|---|---|
| committer | Paul Eggert | 2020-01-04 13:34:06 -0800 |
| commit | add2b2da72babbc72134775499e14fc65da9bd44 (patch) | |
| tree | c39071de49f2569ca52eb39dff09cb58d12ba8c6 | |
| parent | 9bbf17539826a040eda45e88aabd358ed44fabf7 (diff) | |
| download | emacs-add2b2da72babbc72134775499e14fc65da9bd44.tar.gz emacs-add2b2da72babbc72134775499e14fc65da9bd44.zip | |
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.
| -rw-r--r-- | src/alloc.c | 35 |
1 files changed, 18 insertions, 17 deletions
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, | |||
| 1831 | b->next_free = data; | 1831 | b->next_free = data; |
| 1832 | large_sblocks = b; | 1832 | large_sblocks = b; |
| 1833 | } | 1833 | } |
| 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 | } | ||
| 1851 | else | 1834 | else |
| 1852 | { | 1835 | { |
| 1853 | b = current_sblock; | 1836 | 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 | |||
| 1854 | data = b->next_free; | 1855 | data = b->next_free; |
| 1855 | if (clearit) | 1856 | if (clearit) |
| 1856 | memset (SDATA_DATA (data), 0, nbytes); | 1857 | memset (SDATA_DATA (data), 0, nbytes); |