Compare variant_name with "!v" only if long enough

Various places call SetVoiceStack with "" for the variant_name. This
causes -fsanitize=address to fail with an overflow as the call to
memcmp is checking the first 2 bytes, and there is only 1 byte
available.
This commit is contained in:
Reece H. Dunn
2018-03-21 21:16:08 +00:00
parent a08d2c7bfb
commit c9ca77a4d4
+1 -1
View File
@@ -599,7 +599,7 @@ void SetVoiceStack(espeak_VOICE *v, const char *variant_name)
sp->voice_age = v->age;
sp->voice_gender = v->gender;
if (memcmp(variant_name, "!v", 2) == 0)
if (strlen(variant_name) >= 2 && memcmp(variant_name, "!v", 2) == 0)
variant_name += 3; // strip variant directory name, !v plus PATHSEP
strncpy0(base_voice_variant_name, variant_name, sizeof(base_voice_variant_name));
memcpy(&base_voice, &current_voice_selected, sizeof(base_voice));