Browse Source

Fix a null pointer dereference in DoVoiceChange(synthesize.c). [Coverity]

master
Reece H. Dunn 9 years ago
parent
commit
69355ed568
2 changed files with 6 additions and 4 deletions
  1. 5
    3
      src/libespeak-ng/synthesize.c
  2. 1
    1
      src/libespeak-ng/voice.h

+ 5
- 3
src/libespeak-ng/synthesize.c View File

#include "config.h" #include "config.h"


#include <ctype.h> #include <ctype.h>
#include <errno.h>
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
} }
#endif #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() // allocate memory for a copy of the voice data, and free it in wavegenfill()
voice_t *v2; 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)); memcpy(v2, v, sizeof(voice_t));
wcmdq[wcmdq_tail][0] = WCMD_VOICE; wcmdq[wcmdq_tail][0] = WCMD_VOICE;
wcmdq[wcmdq_tail][2] = (intptr_t)v2; wcmdq[wcmdq_tail][2] = (intptr_t)v2;
WcmdqInc(); WcmdqInc();
return ENS_OK;
} }


void DoEmbedded(int *embix, int sourceix) void DoEmbedded(int *embix, int sourceix)

+ 1
- 1
src/libespeak-ng/voice.h View File

espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name); espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name);
voice_t *LoadVoice(const char *voice_name, int control); voice_t *LoadVoice(const char *voice_name, int control);
voice_t *LoadVoiceVariant(const char *voice_name, int variant); 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 WVoiceChanged(voice_t *wvoice);
void WavegenSetVoice(voice_t *v); void WavegenSetVoice(voice_t *v);
void ReadTonePoints(char *string, int *tone_pts); void ReadTonePoints(char *string, int *tone_pts);

Loading…
Cancel
Save