From cb3699746c2d8e262920367497b93f8e4da4a874 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Wed, 6 Jan 2016 20:22:58 +0000 Subject: [PATCH] Check the return value of sscanf in LoadVoice(voices.c) [clang scan-build] --- src/libespeak-ng/voices.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/libespeak-ng/voices.c b/src/libespeak-ng/voices.c index 6f08f4ae..e5521aa4 100644 --- a/src/libespeak-ng/voices.c +++ b/src/libespeak-ng/voices.c @@ -719,15 +719,13 @@ voice_t *LoadVoice(const char *vname, int control) VoiceFormant(p); break; case V_PITCH: - { - double factor; // default is pitch 82 118 - n = sscanf(p, "%d %d", &pitch1, &pitch2); - voice->pitch_base = (pitch1 - 9) << 12; - voice->pitch_range = (pitch2 - pitch1) * 108; - factor = (double)(pitch1 - 82)/82; - voice->formant_factor = (int)((1+factor/4) * 256); // nominal formant shift for a different voice pitch - } + if (sscanf(p, "%d %d", &pitch1, &pitch2) == 2) { + voice->pitch_base = (pitch1 - 9) << 12; + voice->pitch_range = (pitch2 - pitch1) * 108; + double factor = (double)(pitch1 - 82)/82; + voice->formant_factor = (int)((1+factor/4) * 256); // nominal formant shift for a different voice pitch + } break; case V_STRESSLENGTH: // stressLength stress_lengths_set = Read8Numbers(p, stress_lengths);