mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-30 06:12:29 +00:00
encoding.c: Don't crash when passing a NULL string to LookupMnem.
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
int LookupMnem(MNEM_TAB *table, const char *string)
|
||||
{
|
||||
while (table->mnem != NULL) {
|
||||
if (strcmp(string, table->mnem) == 0)
|
||||
if (string && strcmp(string, table->mnem) == 0)
|
||||
return table->value;
|
||||
table++;
|
||||
}
|
||||
|
||||
+2
-1
@@ -27,8 +27,9 @@
|
||||
void
|
||||
test_unknown_encoding()
|
||||
{
|
||||
printf("testing unknown encoding\n");
|
||||
printf("testing unknown encodings\n");
|
||||
|
||||
assert(espeak_ng_EncodingFromName(NULL) == ESPEAKNG_ENCODING_UNKNOWN);
|
||||
assert(espeak_ng_EncodingFromName("") == ESPEAKNG_ENCODING_UNKNOWN);
|
||||
assert(espeak_ng_EncodingFromName("abcxyz") == ESPEAKNG_ENCODING_UNKNOWN);
|
||||
assert(espeak_ng_EncodingFromName("US") == ESPEAKNG_ENCODING_UNKNOWN); // wrong case
|
||||
|
||||
Reference in New Issue
Block a user