Browse Source

Do not overflow ph_buf

With emojis, phoneme strings can be very long
master
Samuel Thibault 3 years ago
parent
commit
f60a27a7cd
2 changed files with 5 additions and 2 deletions
  1. 4
    2
      src/libespeak-ng/dictionary.c
  2. 1
    0
      src/libespeak-ng/translate.h

+ 4
- 2
src/libespeak-ng/dictionary.c View File

@@ -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);
}


+ 1
- 0
src/libespeak-ng/translate.h View File

@@ -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)


Loading…
Cancel
Save