Browse Source

vi: Fix overflow due to lengthmod (#2103)

master
Samuel Thibault 5 months ago
parent
commit
d890919134
No account linked to committer's email address

+ 1
- 1
phsource/ph_vietnam View File

@@ -772,7 +772,7 @@ phoneme N // si**ng**
ELSE
Vowelout f1=3 f2=2300 300 400 f3=-200 80 len=40 rms=20 brk
ENDIF
lengthmod 12 // longer than 'n'
lengthmod 9 // longer than 'n'
IF thisPh(isWordEnd) THEN
length 163
ENDIF

+ 2
- 0
src/libespeak-ng/compiledata.c View File

@@ -30,6 +30,7 @@
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include <assert.h>

#include <espeak-ng/espeak_ng.h>
#include <espeak-ng/speak_lib.h>
@@ -1898,6 +1899,7 @@ static int CompilePhoneme(CompileContext *ctx, int compile_phoneme)
break;
case i_LENGTH_MOD:
value = NextItem(ctx, tNUMBER);
assert(value < LENGTH_MOD_LIMIT);
ctx->phoneme_out->length_mod = value;
break;
case i_IPA_NAME:

+ 4
- 4
src/libespeak-ng/setlengths.c View File

@@ -743,7 +743,7 @@ void CalcLengths(Translator *tr)
// indexes are the "length_mod" value for the following phonemes

// use this table if vowel is not the last in the word
static const unsigned char length_mods_en[100] = {
static const unsigned char length_mods_en[LENGTH_MOD_LIMIT * LENGTH_MOD_LIMIT] = {
// a , t s n d z r N <- next
100, 120, 100, 105, 100, 110, 110, 100, 95, 100, // a <- next2
105, 120, 105, 110, 125, 130, 135, 115, 125, 100, // ,
@@ -758,7 +758,7 @@ static const unsigned char length_mods_en[100] = {
};

// as above, but for the last syllable in a word
static const unsigned char length_mods_en0[100] = {
static const unsigned char length_mods_en0[LENGTH_MOD_LIMIT * LENGTH_MOD_LIMIT] = {
// a , t s n d z r N <- next
100, 150, 100, 105, 110, 115, 110, 110, 110, 100, // a <- next2
105, 150, 105, 110, 125, 135, 140, 115, 135, 100, // ,
@@ -773,7 +773,7 @@ static const unsigned char length_mods_en0[100] = {
};


static const unsigned char length_mods_equal[100] = {
static const unsigned char length_mods_equal[LENGTH_MOD_LIMIT * LENGTH_MOD_LIMIT] = {
// a , t s n d z r N <- next
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // a <- next2
110, 120, 100, 110, 110, 110, 110, 110, 110, 110, // ,
@@ -801,6 +801,6 @@ void SetLengthMods(Translator *tr, int value)
int value2;

tr->langopts.length_mods0 = tr->langopts.length_mods = length_mod_tabs[value % 100];
if ((value2 = value / 100) != 0)
if ((value2 = value / (LENGTH_MOD_LIMIT * LENGTH_MOD_LIMIT)) != 0)
tr->langopts.length_mods0 = length_mod_tabs[value2];
}

+ 2
- 0
src/libespeak-ng/synthesize.h View File

@@ -327,6 +327,8 @@ typedef struct {

#define i_StressLevel 0x800

#define LENGTH_MOD_LIMIT 10

typedef struct {
int pause_factor;
int clause_pause_factor;

Loading…
Cancel
Save