Check the return value of sscanf in LoadVoice(voices.c) [clang scan-build]

This commit is contained in:
Reece H. Dunn
2016-01-06 20:22:58 +00:00
parent bc8297bf3c
commit cb3699746c
+6 -8
View File
@@ -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);