From 7dad0dfd400a0ff42716ecf8d4a1728c3473858f Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Thu, 22 Mar 2018 20:12:35 +0000 Subject: [PATCH] Prevent TranslateRoman reading stack data from Lookup. --- src/libespeak-ng/dictionary.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index afc59efd..aee3aa4c 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -2980,8 +2980,12 @@ int Lookup(Translator *tr, const char *word, char *ph_out) if (flags[0] & FLAG_TEXTMODE) { say_as = option_sayas; option_sayas = 0; // don't speak replacement word as letter names - strncpy0(text, word1, sizeof(text)); - flags0 = TranslateWord(tr, text, NULL, NULL); + // NOTE: TranslateRoman checks text[-2], so pad the start of text to prevent + // it reading data on the stack. + text[0] = ' '; + text[1] = ' '; + strncpy0(text+2, word1, sizeof(text)-2); + flags0 = TranslateWord(tr, text+2, NULL, NULL); strcpy(ph_out, word_phonemes); option_sayas = say_as; }