From 60767a41c08291454e191fa97a78d921cfefc9a0 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 21 Jul 2022 00:18:16 +0200 Subject: [PATCH] Avoid buffer underflow --- src/libespeak-ng/dictionary.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index 4cd87ded..79412141 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -3085,7 +3085,7 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy) // look for multibyte characters to increase the number of bytes to remove for (len_ending = i = (end_type & 0x3f); i > 0; i--) { // num.of characters of the suffix word_end--; - while ((*word_end & 0xc0) == 0x80) { + while (word_end >= word && (*word_end & 0xc0) == 0x80) { word_end--; // for multibyte characters len_ending++; }