diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index e2bf519b..5579bbae 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -20,6 +20,7 @@ #include "config.h" #include +#include #include #include #include @@ -1061,16 +1062,17 @@ void DoSonicSpeed(int value) } #endif -void DoVoiceChange(voice_t *v) +espeak_ng_STATUS DoVoiceChange(voice_t *v) { // allocate memory for a copy of the voice data, and free it in wavegenfill() voice_t *v2; - - v2 = (voice_t *)malloc(sizeof(voice_t)); + if ((v2 = (voice_t *)malloc(sizeof(voice_t))) == NULL) + return ENOMEM; memcpy(v2, v, sizeof(voice_t)); wcmdq[wcmdq_tail][0] = WCMD_VOICE; wcmdq[wcmdq_tail][2] = (intptr_t)v2; WcmdqInc(); + return ENS_OK; } void DoEmbedded(int *embix, int sourceix) diff --git a/src/libespeak-ng/voice.h b/src/libespeak-ng/voice.h index 4ce2961f..00161c5f 100644 --- a/src/libespeak-ng/voice.h +++ b/src/libespeak-ng/voice.h @@ -82,7 +82,7 @@ const char *SelectVoice(espeak_VOICE *voice_select, int *found); espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name); voice_t *LoadVoice(const char *voice_name, int control); voice_t *LoadVoiceVariant(const char *voice_name, int variant); -void DoVoiceChange(voice_t *v); +espeak_ng_STATUS DoVoiceChange(voice_t *v); void WVoiceChanged(voice_t *wvoice); void WavegenSetVoice(voice_t *v); void ReadTonePoints(char *string, int *tone_pts);