From f1afee2ddfaa280680dabab424affe32b531cf59 Mon Sep 17 00:00:00 2001 From: jonsd Date: Fri, 22 Feb 2008 00:05:11 +0000 Subject: [PATCH] Possible fix to a segfault when wordgap feature is used. git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@147 d46cf337-b52f-0410-862d-fd96e6ae7743 --- src/phonemelist.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/phonemelist.cpp b/src/phonemelist.cpp index 4a186f3d..69a00778 100755 --- a/src/phonemelist.cpp +++ b/src/phonemelist.cpp @@ -176,7 +176,6 @@ void Translator::MakePhonemeList(int post_pause, int start_sentence) int ix=0; int j; int insert_ph = 0; - int insert_synthflags = 0; PHONEME_LIST *phlist; PHONEME_TAB *ph; PHONEME_TAB *prev, *next, *next2; @@ -193,6 +192,7 @@ void Translator::MakePhonemeList(int post_pause, int start_sentence) static PHONEME_LIST2 ph_list2_null = {0,0,0,0,0}; PHONEME_LIST2 *plist2 = &ph_list2_null; + PHONEME_LIST2 *plist2_inserted = NULL; phlist = phoneme_list; end_sourceix = ph_list2[n_ph_list2-1].sourceix; @@ -313,13 +313,16 @@ void Translator::MakePhonemeList(int post_pause, int start_sentence) if(insert_ph != 0) { // we have a (linking) phoneme which we need to insert here - j--; next = phoneme_tab[plist2->phcode]; // this phoneme, i.e. after the insert - plist2 = &ph_list2_null; + + // re-use the previous entry for the inserted phoneme. + // That's OK because we don't look backwards from plist2 + j--; + plist2 = plist2_inserted = &ph_list3[j]; + memset(plist2, 0, sizeof(*plist2)); + plist2->phcode = insert_ph; ph = phoneme_tab[insert_ph]; - plist2->synthflags = insert_synthflags; insert_ph = 0; - insert_synthflags = 0; } else { @@ -548,13 +551,16 @@ void Translator::MakePhonemeList(int post_pause, int start_sentence) } } - if((x = (langopts.word_gap & 0x7)) != 0) + if(plist2 != plist2_inserted) { - insert_ph = pause_phonemes[x]; - } - if(option_wordgap > 0) - { - insert_ph = phonPAUSE_LONG; + if((x = (langopts.word_gap & 0x7)) != 0) + { + insert_ph = pause_phonemes[x]; + } + if(option_wordgap > 0) + { + insert_ph = phonPAUSE_LONG; + } } }