From 5fac0d4fec1d22bb9124bf5f219148c66d368e09 Mon Sep 17 00:00:00 2001 From: mbkma Date: Wed, 17 Mar 2021 23:30:26 +0100 Subject: mp-serializer: fix memory leaks reported by valgrind --- src/mp-serializer.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mp-serializer.c b/src/mp-serializer.c index 366355f..af45944 100644 --- a/src/mp-serializer.c +++ b/src/mp-serializer.c @@ -637,14 +637,20 @@ mp_serializer_class_init(MpSerializerClass *klass) static void mp_serializer_init(MpSerializer *serializer) { - gchar *radix, *tsep; + gchar *radix, *utf8_radix, *tsep; serializer->priv = mp_serializer_get_instance_private (serializer); radix = nl_langinfo(RADIXCHAR); - serializer->priv->radix = radix ? g_utf8_get_char(g_locale_to_utf8(radix, -1, NULL, NULL, NULL)) : '.'; + utf8_radix = g_locale_to_utf8(radix, -1, NULL, NULL, NULL); + serializer->priv->radix = radix ? g_utf8_get_char(utf8_radix) : '.'; + g_free(utf8_radix); tsep = nl_langinfo(THOUSEP); if (tsep && tsep[0] != '\0') - serializer->priv->tsep = g_utf8_get_char(g_locale_to_utf8(tsep, -1, NULL, NULL, NULL)); + { + gchar *utf8_tsep = g_locale_to_utf8(tsep, -1, NULL, NULL, NULL); + serializer->priv->tsep = g_utf8_get_char(utf8_tsep); + g_free(utf8_tsep); + } else serializer->priv->tsep = ' '; serializer->priv->tsep_count = 3; -- cgit v1.2.1