From b5c20b801c0e3c713029ba3222e769194f8a0e0b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 20 May 2005 20:51:38 +0000 Subject: [PATCH] dup the new value before freeing the old, just in case. (#172142, Morten 2005-05-20 Matthias Clasen * gvaluetypes.c (g_value_set_string): dup the new value before freeing the old, just in case. (#172142, Morten Welinder) --- gobject/ChangeLog | 6 ++++++ gobject/gvaluetypes.c | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 336408bc3..3a6cb5c3a 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,9 @@ +2005-05-20 Matthias Clasen + + * gvaluetypes.c (g_value_set_string): dup the new value + before freeing the old, just in case. (#172142, Morten + Welinder) + 2005-05-13 Matthias Clasen * glib-genmarshal.1: Mention 64bit integer types. diff --git a/gobject/gvaluetypes.c b/gobject/gvaluetypes.c index 48d332ac8..b5380eefb 100644 --- a/gobject/gvaluetypes.c +++ b/gobject/gvaluetypes.c @@ -739,13 +739,18 @@ void g_value_set_string (GValue *value, const gchar *v_string) { + gchar *new_val; + g_return_if_fail (G_VALUE_HOLDS_STRING (value)); - + + new_val = g_strdup (v_string); + if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS) value->data[1].v_uint = 0; else g_free (value->data[0].v_pointer); - value->data[0].v_pointer = g_strdup (v_string); + + value->data[0].v_pointer = new_val; } void