fix(mbyte): check for utf8proc_map() failure (#30531)

This commit is contained in:
zeertzjq
2024-09-27 07:40:46 +08:00
committed by GitHub
parent 98d1c0ebef
commit a9287dd882
2 changed files with 13 additions and 3 deletions

View File

@@ -1380,11 +1380,15 @@ int utf_fold(int a)
}
utf8proc_uint8_t input_str[16] = { 0 };
utf8proc_encode_char(a, input_str);
if (utf8proc_encode_char(a, input_str) <= 0) {
return a;
}
utf8proc_uint8_t *fold_str_utf;
utf8proc_map((utf8proc_uint8_t *)input_str, 0, &fold_str_utf,
UTF8PROC_NULLTERM | UTF8PROC_CASEFOLD);
if (utf8proc_map((utf8proc_uint8_t *)input_str, 0, &fold_str_utf,
UTF8PROC_NULLTERM | UTF8PROC_CASEFOLD) < 0) {
return a;
}
int fold_codepoint_utf = utf_ptr2char((char *)fold_str_utf);