Fix bug detected by scan-build

This commit is contained in:
Patrick Pelissier committed 2017-12-30 10:30:49 +01:00
1 parent 73fda748fe
commit 57ec4514d4
2 files changed
+5 -2

No files matched your search

+2 -2
View File
@@ -982,7 +982,7 @@ static inline size_t
string_length_u(string_t str)
{
STRING_CONTRACT(str);
return stringi_utf8_length(str->ptr);
return stringi_utf8_length(string_get_cstr(str));
}
/* Check if a string is a valid UTF8 encoded stream */
@@ -990,7 +990,7 @@ static inline bool
string_utf8_p(string_t str)
{
STRING_CONTRACT(str);
return stringi_utf8_valid_str_p(str->ptr);
return stringi_utf8_valid_str_p(string_get_cstr(str));
}
+3
View File
@@ -36,6 +36,9 @@ static void test_utf8_basic(void)
{
string_t s;
string_init (s);
assert (string_utf8_p(s) == true);
assert (string_length_u(s) == 0);
/* Test internal encode + decode for all characters */
for (string_unicode_t i = 1; i < 0x10ffff; i++) {