]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
adsfasdf utf8-changes
authorRay Strode <rstrode@redhat.com>
Sun, 10 Dec 2023 16:29:24 +0000 (11:29 -0500)
committerRay Strode <rstrode@redhat.com>
Sun, 10 Dec 2023 16:29:24 +0000 (11:29 -0500)
src/libply/ply-utils.c

index 8acc79e1ef6d5d6c99d8266119a6cce31ed55711..6154bcafc1e77451b05dff77b6933c2cbe555a1e 100644 (file)
@@ -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';