From: Ray Strode Date: Sun, 10 Dec 2023 16:29:24 +0000 (-0500) Subject: adsfasdf X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Futf8-changes;p=thirdparty%2Fplymouth.git adsfasdf --- diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c index 8acc79e1..6154bcaf 100644 --- a/src/libply/ply-utils.c +++ b/src/libply/ply-utils.c @@ -812,6 +812,10 @@ ply_utf8_string_remove_last_character (char **string, size_t size = *n; bytes_to_remove = MIN (size, PLY_UTF8_CHARACTER_SIZE_MAX); + + if (size == 0) + return; + do { ply_utf8_character_byte_type_t previous_character_byte_type; const char *previous_character = bytes + size - bytes_to_remove; @@ -822,6 +826,9 @@ ply_utf8_string_remove_last_character (char **string, if (bytes_to_remove < previous_character_size) break; + if (previous_character_byte_type == PLY_UTF8_CHARACTER_BYTE_TYPE_END_OF_STRING) + break; + if (PLY_UTF8_CHARACTER_BYTE_TYPE_IS_NOT_LEADING (previous_character_byte_type)) bytes_to_remove--; else if (previous_character_size > bytes_to_remove) @@ -831,7 +838,7 @@ ply_utf8_string_remove_last_character (char **string, } while (previous_character_size <= bytes_to_remove); - if (bytes_to_remove <= size) { + if (bytes_to_remove < size) { size_t new_size; new_size = size - bytes_to_remove; bytes[new_size - 1] = '\0';