summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormbkma <[email protected]>2021-03-17 23:30:26 +0100
committerrbuj <[email protected]>2021-03-18 09:32:36 +0100
commitbd7e311c5050712defbda9b08417985ff4875c79 (patch)
treec96fda23e3a0ba6b5bd3ab502e0377fb6b11db54
parent3bbbbe4489c113144cf95f1afad7977e7a81fe52 (diff)
downloadmate-calc-bd7e311c5050712defbda9b08417985ff4875c79.tar.bz2
mate-calc-bd7e311c5050712defbda9b08417985ff4875c79.tar.xz
mp-serializer: fix memory leaks reported by valgrind
-rw-r--r--src/mp-serializer.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mp-serializer.c b/src/mp-serializer.c
index 4067016..0de22c5 100644
--- a/src/mp-serializer.c
+++ b/src/mp-serializer.c
@@ -601,14 +601,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;