summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-04-20 22:26:30 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-04-20 22:31:11 -0700
commitc88a3be8087ad0165415aa87c01f868a7433cb21 (patch)
tree5bba8004c1846653aa514416d31c6b47034df740 /src/buffer.c
parent856d9378a49ec9ec1af2ea74fb9309fe4c39cd1d (diff)
downloademacs-c88a3be8087ad0165415aa87c01f868a7433cb21.tar.gz
Fix string-to-multibyte overlong sequence bug
* src/character.h (MULTIBYTE_LENGTH, MULTIBYTE_LENGTH_NO_CHECK): Remove, replacing with ... (multibyte_length): ... this new function. All callers changed. The new function rejects overlong multibyte forms. * test/src/buffer-tests.el (buffer-multibyte-overlong-sequences): New test.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 5398414e6eb..53b3bd960c4 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2634,8 +2634,7 @@ current buffer is cleared. */)
if (ASCII_CHAR_P (*p))
p++, pos++;
else if (EQ (flag, Qt)
- && ! CHAR_BYTE8_HEAD_P (*p)
- && (bytes = MULTIBYTE_LENGTH (p, pend)) > 0)
+ && 0 < (bytes = multibyte_length (p, pend, true, false)))
p += bytes, pos += bytes;
else
{