diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2020-01-22 23:43:29 -0800 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2020-01-22 23:44:34 -0800 |
| commit | 6f580542c1796d3e7ba4d1dd40b2fe73fe00e5db (patch) | |
| tree | ed853d4d27a2f231d7fe13a4affb723d0ce28eeb /src | |
| parent | 5715eb94e90b33ace59dd4c4ccb6e2122bc6db72 (diff) | |
| download | emacs-6f580542c1796d3e7ba4d1dd40b2fe73fe00e5db.tar.gz | |
Fix crash when sending Gnus message (Bug#39207)
* src/alloc.c (resize_string_data): The string must be multibyte.
When not bothering to reallocate, do bother to change the byte count.
* test/src/alloc-tests.el (aset-nbytes-change) New test.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c index 99d5ca149d5..a35b48cfb22 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1889,7 +1889,7 @@ allocate_string_data (struct Lisp_String *s, tally_consing (needed); } -/* Reallocate the data for STRING when a single character is replaced. +/* Reallocate multibyte STRING data when a single character is replaced. The character is at byte offset CIDX_BYTE in the string. The character being replaced is CLEN bytes long, and the character that will replace it is NEW_CLEN bytes long. @@ -1900,6 +1900,7 @@ unsigned char * resize_string_data (Lisp_Object string, ptrdiff_t cidx_byte, int clen, int new_clen) { + eassume (STRING_MULTIBYTE (string)); sdata *old_sdata = SDATA_OF_STRING (XSTRING (string)); ptrdiff_t nchars = SCHARS (string); ptrdiff_t nbytes = SBYTES (string); @@ -1911,6 +1912,7 @@ resize_string_data (Lisp_Object string, ptrdiff_t cidx_byte, { /* No need to reallocate, as the size change falls within the alignment slop. */ + XSTRING (string)->u.s.size_byte = new_nbytes; new_charaddr = data + cidx_byte; memmove (new_charaddr + new_clen, new_charaddr + clen, nbytes - (cidx_byte + (clen - 1))); |
