encoding.c: Don't crash when passing a NULL string to LookupMnem.

This commit is contained in:
Reece H. Dunn
2017-03-27 21:32:49 +01:00
parent 26f4eb4f8f
commit 887b1c837f
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -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
View File
@@ -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