Fix a SEGFAULT in GetTranslatedPhonemeString.

When running any of the following:

    espeak -x "[[]]"
    espeak --ipa "[[]]"

eSpeak would SEGFAULT. This is because phon_out_buf is NULL as no
phonemes have been written and as this is the first call to
GetTranslatedPhonemeString, the phoneme buffer has not been
allocated yet. However, GetTranslatedPhonemeString attempts to add
a NULL character to the end of the phoneme buffer, and thus crashes.
This commit is contained in:
Reece H. Dunn
2013-08-23 13:35:32 +01:00
parent 9fe782ae66
commit 304d265f46
+5
View File
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* Copyright (C) 2013 Reece H. Dunn *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -769,6 +770,10 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
strcpy(&phon_out_buf[phon_out_ix], phon_buf);
phon_out_ix += len;
}
if (!phon_out_buf)
return("");
phon_out_buf[phon_out_ix] = 0;
return(phon_out_buf);