summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2023-12-10 11:29:24 -0500
committerRay Strode <rstrode@redhat.com>2023-12-10 11:29:24 -0500
commit52e889e7d14f1f8247f3a4437b910a7711b6c1b6 (patch)
treecd9b3119c0d2d51260c011a968df81ab12b2565d
parent6293134438137446a9e2fa4947c7ff730fc27eb2 (diff)
adsfasdfutf8-changes
-rw-r--r--src/libply/ply-utils.c9
1 files changed, 8 insertions, 1 deletions
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';