From b9d27192229fc9be3299a47f5ebd4a3163073a0c Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 11 Apr 2025 14:57:29 +0100 Subject: [PATCH] gboxed: Use new g_string_copy() as boxed copy for GString Rather than reinventing it ourselves. The old version in `gboxed.c` could lose the second half of very long strings, as it truncated the `size_t` string length to the `ssize_t` accepted by `g_string_new_len()`. Signed-off-by: Philip Withnall Helps: #3405 --- gobject/gboxed.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/gobject/gboxed.c b/gobject/gboxed.c index 04cededa0..fce661df2 100644 --- a/gobject/gboxed.c +++ b/gobject/gboxed.c @@ -96,12 +96,6 @@ _g_boxed_type_init (void) g_assert (type == G_TYPE_BOXED); } -static GString * -gstring_copy (GString *src_gstring) -{ - return g_string_new_len (src_gstring->str, src_gstring->len); -} - static void gstring_free (GString *gstring) { @@ -113,7 +107,7 @@ G_DEFINE_BOXED_TYPE (GValue, g_value, value_copy, value_free) G_DEFINE_BOXED_TYPE (GValueArray, g_value_array, g_value_array_copy, g_value_array_free) G_DEFINE_BOXED_TYPE (GDate, g_date, g_date_copy, g_date_free) /* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */ -G_DEFINE_BOXED_TYPE (GString, g_gstring, gstring_copy, gstring_free) +G_DEFINE_BOXED_TYPE (GString, g_gstring, g_string_copy, gstring_free) G_DEFINE_BOXED_TYPE (GHashTable, g_hash_table, g_hash_table_ref, g_hash_table_unref) G_DEFINE_BOXED_TYPE (GArray, g_array, g_array_ref, g_array_unref) G_DEFINE_BOXED_TYPE (GPtrArray, g_ptr_array,g_ptr_array_ref, g_ptr_array_unref)