diff --git a/src/base/system.c b/src/base/system.c index 3bd93ffa0..3c769d6d2 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -2739,6 +2739,9 @@ int str_utf8_comp_nocase(const char *a, const char *b) int str_utf8_comp_nocase_num(const char *a, const char *b, int num) { + if(num <= 0) + return 0; + int code_a; int code_b; const char *old_a = a; diff --git a/src/test/str.cpp b/src/test/str.cpp index 1e75445d1..d934660dc 100644 --- a/src/test/str.cpp +++ b/src/test/str.cpp @@ -72,8 +72,8 @@ TEST(Str, Utf8ToLower) EXPECT_TRUE(str_utf8_comp_nocase(a, b) > 0); EXPECT_TRUE(str_utf8_comp_nocase(b, a) < 0); - EXPECT_TRUE(str_utf8_comp_nocase_num("ÖlÜ", "ölüa", 3) == 0); - EXPECT_TRUE(str_utf8_comp_nocase_num("ÖlÜ", "ölüa", 4) != 0); + EXPECT_TRUE(str_utf8_comp_nocase_num("ÖlÜ", "ölüa", 5) == 0); + EXPECT_TRUE(str_utf8_comp_nocase_num("ÖlÜ", "ölüa", 6) != 0); EXPECT_TRUE(str_utf8_comp_nocase_num("a", "z", 0) == 0); EXPECT_TRUE(str_utf8_comp_nocase_num("a", "z", 1) != 0);