Browse Source

Fix the malloc/realloc usage of phon_out_buf in GetTranslatedPhonemeString(dictionary.c) [msvc /analyze]

master
Reece H. Dunn 9 years ago
parent
commit
f608860a7a
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      src/libespeak-ng/dictionary.c

+ 5
- 3
src/libespeak-ng/dictionary.c View File



if (phon_out_buf == NULL) { if (phon_out_buf == NULL) {
phon_out_size = N_PHON_OUT; phon_out_size = N_PHON_OUT;
if ((phon_out_buf = (char *)realloc(phon_out_buf, phon_out_size)) == NULL) {
if ((phon_out_buf = (char *)malloc(phon_out_size)) == NULL) {
phon_out_size = 0; phon_out_size = 0;
return ""; return "";
} }
if ((phon_out_ix + len) >= phon_out_size) { if ((phon_out_ix + len) >= phon_out_size) {
// enlarge the phoneme buffer // enlarge the phoneme buffer
phon_out_size = phon_out_ix + len + N_PHON_OUT; phon_out_size = phon_out_ix + len + N_PHON_OUT;
if ((phon_out_buf = (char *)realloc(phon_out_buf, phon_out_size)) == NULL) {
char *new_phon_out_buf = (char *)realloc(phon_out_buf, phon_out_size);
if (new_phon_out_buf == NULL) {
phon_out_size = 0; phon_out_size = 0;
return ""; return "";
}
} else
phon_out_buf = new_phon_out_buf;
} }


phon_buf[len] = 0; phon_buf[len] = 0;

Loading…
Cancel
Save