Browse Source

Check malloc/realloc in the flag_stdin codepath of espeak-ng.c.

master
Reece H. Dunn 9 years ago
parent
commit
a64e048c51
1 changed files with 10 additions and 2 deletions
  1. 10
    2
      src/espeak-ng.c

+ 10
- 2
src/espeak-ng.c View File

espeak_Synth(p_text, size+1, 0, POS_CHARACTER, 0, synth_flags, NULL, NULL); espeak_Synth(p_text, size+1, 0, POS_CHARACTER, 0, synth_flags, NULL, NULL);
} else if (flag_stdin) { } else if (flag_stdin) {
int max = 1000; int max = 1000;
p_text = (char *)malloc(max);
if ((p_text = (char *)malloc(max)) == NULL) {
espeak_ng_PrintStatusCodeMessage(ENOMEM, stderr, NULL);
exit(EXIT_FAILURE);
}


if (flag_stdin == 2) { if (flag_stdin == 2) {
// line by line input on stdin // line by line input on stdin
p_text[ix++] = fgetc(stdin); p_text[ix++] = fgetc(stdin);
if (ix >= (max-1)) { if (ix >= (max-1)) {
max += 1000; max += 1000;
p_text = (char *)realloc(p_text, max);
char *new_text = (char *)realloc(p_text, max);
if (new_text == NULL) {
free(p_text);
espeak_ng_PrintStatusCodeMessage(ENOMEM, stderr, NULL);
exit(EXIT_FAILURE);
}
} }
} }
if (ix > 0) { if (ix > 0) {

Loading…
Cancel
Save