Browse Source

Mark static arrays undefined when they are reused

So valgrind can potentially catch e.g. missing \0.
master
Samuel Thibault 3 years ago
parent
commit
24e1eaa0cc

+ 2
- 0
src/libespeak-ng/compiledict.c View File

char suffix[20]; char suffix[20];
static char output[80]; static char output[80];


MAKE_MEM_UNDEFINED(&output, sizeof(output));

static const char symbols[] = { static const char symbols[] = {
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
'&', '%', '+', '#', 'S', 'D', 'Z', 'A', 'L', '!', '&', '%', '+', '#', 'S', 'D', 'Z', 'A', 'L', '!',

+ 2
- 0
src/libespeak-ng/dictionary.c View File

char word[N_WORD_BYTES]; char word[N_WORD_BYTES];
static char word_replacement[N_WORD_BYTES]; static char word_replacement[N_WORD_BYTES];


MAKE_MEM_UNDEFINED(&word_replacement, sizeof(word_replacement));

length = 0; length = 0;
word2 = word1 = *wordptr; word2 = word1 = *wordptr;



+ 7
- 1
src/libespeak-ng/readclause.c View File

static char buf[5]; static char buf[5];
char *p; char *p;


MAKE_MEM_UNDEFINED(&buf, sizeof(buf));

p = buf; p = buf;
for (ix = 3; ix >= 0; ix--) { for (ix = 3; ix >= 0; ix--) {
if ((*p = word >> (ix*8)) != 0) if ((*p = word >> (ix*8)) != 0)
char *string; char *string;
static char buf[60]; static char buf[60];


MAKE_MEM_UNDEFINED(&buf, sizeof(buf));

buf[0] = 0; buf[0] = 0;
flags[0] = 0; flags[0] = 0;
flags[1] = 0; flags[1] = 0;
c1 = c2; c1 = c2;


if (ungot_string_ix >= 0) { if (ungot_string_ix >= 0) {
if (ungot_string[ungot_string_ix] == 0)
if (ungot_string[ungot_string_ix] == 0) {
MAKE_MEM_UNDEFINED(&ungot_string, sizeof(ungot_string));
ungot_string_ix = -1; ungot_string_ix = -1;
}
} }


if ((ungot_string_ix == 0) && (ungot_char2 == 0)) if ((ungot_string_ix == 0) && (ungot_char2 == 0))

+ 3
- 0
src/libespeak-ng/ssml.c View File

#include "synthesize.h" // for SPEED_FACTORS, speed #include "synthesize.h" // for SPEED_FACTORS, speed
#include "translate.h" // for CTRL_EMBEDDED, IsDigit09, utf8_out #include "translate.h" // for CTRL_EMBEDDED, IsDigit09, utf8_out
#include "voice.h" // for SelectVoice, SelectVoiceByName #include "voice.h" // for SelectVoice, SelectVoiceByName
#include "speech.h" // for MAKE_MEM_UNDEFINED


static const MNEM_TAB ssmltags[] = { static const MNEM_TAB ssmltags[] = {
{ "speak", SSML_SPEAK }, { "speak", SSML_SPEAK },
char language[40]; char language[40];
char buf[80]; char buf[80];


MAKE_MEM_UNDEFINED(&voice_name, sizeof(voice_name));

strcpy(voice_name, ssml_stack[0].voice_name); strcpy(voice_name, ssml_stack[0].voice_name);
strcpy(language, ssml_stack[0].language); strcpy(language, ssml_stack[0].language);
voice_select.age = ssml_stack[0].voice_age; voice_select.age = ssml_stack[0].voice_age;

+ 2
- 0
src/libespeak-ng/synth_mbrola.c View File

char buf[50]; char buf[50];
static char output[50]; static char output[50];


MAKE_MEM_UNDEFINED(&output, sizeof(output));

output[0] = 0; output[0] = 0;
pitch_env = envelope_data[env]; pitch_env = envelope_data[env];



+ 2
- 0
src/libespeak-ng/synthdata.c View File

frame_t *frame; frame_t *frame;
static frameref_t frames_buf[N_SEQ_FRAMES]; static frameref_t frames_buf[N_SEQ_FRAMES];


MAKE_MEM_UNDEFINED(&frames_buf, sizeof(frames_buf));

seq = (SPECT_SEQ *)(&phondata_ptr[fmt_params->fmt_addr]); seq = (SPECT_SEQ *)(&phondata_ptr[fmt_params->fmt_addr]);
seqk = (SPECT_SEQK *)seq; seqk = (SPECT_SEQK *)seq;
nf = seq->n_frames; nf = seq->n_frames;

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

#include "translate.h" // for translator, LANGUAGE_OPTIONS, Trans... #include "translate.h" // for translator, LANGUAGE_OPTIONS, Trans...
#include "voice.h" // for voice_t, voice, LoadVoiceVariant #include "voice.h" // for voice_t, voice, LoadVoiceVariant
#include "wavegen.h" // for WcmdqInc, WcmdqFree, WcmdqStop #include "wavegen.h" // for WcmdqInc, WcmdqFree, WcmdqStop
#include "speech.h" // for MAKE_MEM_UNDEFINED


static void SmoothSpect(void); static void SmoothSpect(void);


int ix; int ix;
static char buf[5]; static char buf[5];


MAKE_MEM_UNDEFINED(&buf, sizeof(buf));

for (ix = 0; ix < 4; ix++) for (ix = 0; ix < 4; ix++)
buf[ix] = word >> (ix*8); buf[ix] = word >> (ix*8);
buf[4] = 0; buf[4] = 0;
ix++; ix++;
if (ix >= N_FRAME_POOL) if (ix >= N_FRAME_POOL)
ix = 0; ix = 0;

MAKE_MEM_UNDEFINED(&frame_pool[ix], sizeof(frame_pool[ix]));
return &frame_pool[ix]; return &frame_pool[ix];
} }



+ 2
- 0
src/libespeak-ng/translate.c View File

if (tr == NULL) if (tr == NULL)
return; return;


MAKE_MEM_UNDEFINED(&voice_change_name, sizeof(voice_change_name));

embedded_ix = 0; embedded_ix = 0;
embedded_read = 0; embedded_read = 0;
pre_pause = 0; pre_pause = 0;

+ 6
- 0
src/libespeak-ng/voices.c View File

static char variant_name[40]; static char variant_name[40];
char variant_prefix[5]; char variant_prefix[5];


MAKE_MEM_UNDEFINED(&variant_name, sizeof(variant_name));
variant_name[0] = 0; variant_name[0] = 0;
sprintf(variant_prefix, "!v%c", PATHSEP); sprintf(variant_prefix, "!v%c", PATHSEP);
if (add_dir == 0) if (add_dir == 0)
static espeak_VOICE voice_variants[N_VOICE_VARIANTS]; static espeak_VOICE voice_variants[N_VOICE_VARIANTS];
static char voice_id[50]; static char voice_id[50];


MAKE_MEM_UNDEFINED(&voice_variants, sizeof(voice_variants));
MAKE_MEM_UNDEFINED(&voice_id, sizeof(voice_id));

*found = 1; *found = 1;
memcpy(&voice_select2, voice_select, sizeof(voice_select2)); memcpy(&voice_select2, voice_select, sizeof(voice_select2));


// no language is specified. Get language from the named voice // no language is specified. Get language from the named voice
static char buf[60]; static char buf[60];


MAKE_MEM_UNDEFINED(&buf, sizeof(buf));

if (voice_select2.name == NULL) { if (voice_select2.name == NULL) {
if ((voice_select2.name = voice_select2.identifier) == NULL) if ((voice_select2.name = voice_select2.identifier) == NULL)
voice_select2.name = ESPEAKNG_DEFAULT_VOICE; voice_select2.name = ESPEAKNG_DEFAULT_VOICE;

Loading…
Cancel
Save