From f1ce2ec423e33b12ec1efdab5bb559b0e74b71c9 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 4 Apr 2022 22:42:17 +0200 Subject: [PATCH] Mark re-used ph_list2 array as undefined And fix looking after end of array. --- src/libespeak-ng/phonemelist.c | 2 +- src/libespeak-ng/translate.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libespeak-ng/phonemelist.c b/src/libespeak-ng/phonemelist.c index 7446ea30..88604e5b 100644 --- a/src/libespeak-ng/phonemelist.c +++ b/src/libespeak-ng/phonemelist.c @@ -72,7 +72,7 @@ static int SubstitutePhonemes(PHONEME_LIST *plist_out) next = phoneme_tab[ph_list2[ix+1].phcode]; word_end = false; - if ((plist2+1)->sourceix || ((next != 0) && (next->type == phPAUSE))) + if (ix == n_ph_list2 -1 || (plist2+1)->sourceix || ((next != 0) && (next->type == phPAUSE))) word_end = true; // this phoneme is the end of a word // check whether a Voice has specified that we should replace this phoneme diff --git a/src/libespeak-ng/translate.c b/src/libespeak-ng/translate.c index 0914619a..3acff839 100644 --- a/src/libespeak-ng/translate.c +++ b/src/libespeak-ng/translate.c @@ -42,6 +42,7 @@ #include "synthesize.h" // for PHONEME_LIST2, N_PHONEME_LIST, PHON... #include "ucd/ucd.h" // for ucd_toupper #include "voice.h" // for voice, voice_t +#include "speech.h" // for MAKE_MEM_UNDEFINED Translator *translator = NULL; // the main translator Translator *translator2 = NULL; // secondary translator for certain words @@ -2045,6 +2046,7 @@ void TranslateClause(Translator *tr, int *tone_out, char **voice_change) } } + MAKE_MEM_UNDEFINED(&ph_list2, sizeof(ph_list2)); memset(&ph_list2[0], 0, sizeof(ph_list2[0])); ph_list2[0].phcode = phonPAUSE_SHORT;