From 304d265f462fa4854c7d1f953131c69937a2fe74 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Fri, 23 Aug 2013 13:30:45 +0100 Subject: [PATCH] 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. --- src/dictionary.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dictionary.cpp b/src/dictionary.cpp index 87ef77b0..45f9da2f 100644 --- a/src/dictionary.cpp +++ b/src/dictionary.cpp @@ -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);