Browse Source

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.
master
Reece H. Dunn 12 years ago
parent
commit
304d265f46
1 changed files with 5 additions and 0 deletions
  1. 5
    0
      src/dictionary.cpp

+ 5
- 0
src/dictionary.cpp View File

/*************************************************************************** /***************************************************************************
* Copyright (C) 2005 to 2013 by Jonathan Duddington * * Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: [email protected] * * email: [email protected] *
* Copyright (C) 2013 Reece H. Dunn *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *
strcpy(&phon_out_buf[phon_out_ix], phon_buf); strcpy(&phon_out_buf[phon_out_ix], phon_buf);
phon_out_ix += len; phon_out_ix += len;
} }

if (!phon_out_buf)
return("");

phon_out_buf[phon_out_ix] = 0; phon_out_buf[phon_out_ix] = 0;


return(phon_out_buf); return(phon_out_buf);

Loading…
Cancel
Save