Fix out-of-bound vowel_stress access

./src/espeak-ng -v ar --path=$PWD 5777

would access out of the vowel_stress array, because GetVowelStress, in the
phcode == phonSYLLABIC case, only increments count if stress is 0.  This
code seems fishy, and is not coherent with the loop in SetWordStress.  I
made it similar to the other case above, thus fixing the out-of-bound
access.

This is modifiying the stress in the tn test, I don't know whether this
is expected.
This commit is contained in:
Samuel Thibault
2022-08-28 17:13:32 +02:00
parent 8789e1e8e1
commit 6284272c31
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -927,8 +927,9 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, signed char *
} else if (phcode == phonSYLLABIC) {
// previous consonant phoneme is syllablic
vowel_stress[count] = (char)stress;
if ((stress == 0) && (control & 1))
vowel_stress[count++] = STRESS_IS_UNSTRESSED; // syllabic consonant, usually unstressed
if ((stress < 0) && (control & 1))
vowel_stress[count] = STRESS_IS_UNSTRESSED; // syllabic consonant, usually unstressed
count++;
}
*ph_out++ = phcode;
@@ -1473,6 +1474,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
}
p = phonetic;
/* Note: v progression has to strictly follow the vowel_stress production in GetVowelStress */
while (((phcode = *p++) != 0) && (output < max_output)) {
if ((ph = phoneme_tab[phcode]) == NULL)
continue;
@@ -1482,6 +1484,8 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
else if (((ph->type == phVOWEL) && !(ph->phflags & phNONSYLLABIC)) || (*p == phonSYLLABIC)) {
// a vowel, or a consonant followed by a syllabic consonant marker
assert(v <= vowel_count);
v_stress = vowel_stress[v];
tr->prev_last_stress = v_stress;