mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-10-31 05:35:35 +00:00
Do not overflow ph_buf
With emojis, phoneme strings can be very long
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include <string.h>
|
||||
#include <wctype.h>
|
||||
#include <wchar.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <espeak-ng/espeak_ng.h>
|
||||
#include <espeak-ng/speak_lib.h>
|
||||
@@ -2228,7 +2229,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
int dict_flags0 = 0;
|
||||
MatchRecord match1;
|
||||
MatchRecord match2;
|
||||
char ph_buf[40];
|
||||
char ph_buf[N_PHONEME_BYTES];
|
||||
char word_copy[N_WORD_BYTES];
|
||||
static const char str_pause[2] = { phonPAUSE_NOLINK, 0 };
|
||||
|
||||
@@ -2660,8 +2661,9 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
phonetic[0] = 0;
|
||||
phoneme_len = 0;
|
||||
} else {
|
||||
strcpy(phonetic, p);
|
||||
phoneme_len = strlen(p);
|
||||
assert(phoneme_len < N_PHONEME_BYTES);
|
||||
strcpy(phonetic, p);
|
||||
p += (phoneme_len + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ extern "C"
|
||||
|
||||
#define N_WORD_PHONEMES 200 // max phonemes in a word
|
||||
#define N_WORD_BYTES 160 // max bytes for the UTF8 characters in a word
|
||||
#define N_PHONEME_BYTES 160 // max bytes for a phoneme
|
||||
#define N_CLAUSE_WORDS 300 // max words in a clause
|
||||
#define N_TR_SOURCE 800 // the source text of a single clause (UTF8 bytes)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user