From 8e7f4e7e3dcc10d375ac8b30d2aeba2f770b01fe Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Tue, 12 Jan 2016 21:23:45 +0000 Subject: [PATCH] Fix the realloc usage of outbuffer in WaveCallback(wavegen.c) --- src/libespeak-ng/wavegen.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libespeak-ng/wavegen.c b/src/libespeak-ng/wavegen.c index 243acdb4..9d8706fb 100644 --- a/src/libespeak-ng/wavegen.c +++ b/src/libespeak-ng/wavegen.c @@ -380,10 +380,11 @@ static int WaveCallback(const void *inputBuffer, void *outputBuffer, // make a buffer 3x size of the portaudio output ix = pa_size*3; if (ix > outbuffer_size) { - outbuffer = (unsigned char *)realloc(outbuffer, ix); - if (outbuffer == NULL) { + unsigned char *new_outbuffer = (unsigned char *)realloc(outbuffer, ix); + if (new_outbuffer == NULL) fprintf(stderr, "espeak: out of memory\n"); - } + else + outbuffer = new_outbuffer; outbuffer_size = ix; out_ptr = NULL; }