forked from github/server
fix an endless loop in unicode_utf8_to_cp437 for characters not in the table.
This commit is contained in:
parent
23b9774495
commit
8728fccaec
|
@ -506,10 +506,14 @@ size_t * length)
|
|||
*cp_character = (char)xref[m].cp437;
|
||||
break;
|
||||
}
|
||||
else if (xref[m].ucs4 < ucs4_character)
|
||||
l = m;
|
||||
else
|
||||
r = m;
|
||||
else if (xref[m].ucs4 < ucs4_character) {
|
||||
if (l == m) l = r;
|
||||
else l = m;
|
||||
}
|
||||
else {
|
||||
if (r == m) r = l;
|
||||
else r = m;
|
||||
}
|
||||
}
|
||||
if (l == r) {
|
||||
*cp_character = '?';
|
||||
|
|
|
@ -16,9 +16,20 @@ static void test_unicode_tolower(CuTest * tc)
|
|||
CuAssertStrEquals(tc, "helloX", buffer);
|
||||
}
|
||||
|
||||
static void test_unicode_utf8_to_cp437(CuTest *tc)
|
||||
{
|
||||
const char utf8_str[4] = { 0xc3, 0x98, 'l', 0 }; // Øl
|
||||
char ch;
|
||||
size_t sz;
|
||||
CuAssertIntEquals(tc, 0, unicode_utf8_to_cp437(&ch, utf8_str, &sz));
|
||||
CuAssertIntEquals(tc, 2, sz);
|
||||
CuAssertIntEquals(tc, '?', ch);
|
||||
}
|
||||
|
||||
CuSuite *get_unicode_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_unicode_tolower);
|
||||
SUITE_ADD_TEST(suite, test_unicode_utf8_to_cp437);
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue