[libgweather] location: Don't release libxml-allocated memory with g_free()
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather] location: Don't release libxml-allocated memory with g_free()
- Date: Mon, 5 Jun 2017 04:45:21 +0000 (UTC)
commit 9b08eeadf215580358d0f53ac0f54c9acdde7384
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Apr 22 04:30:37 2017 +0200
location: Don't release libxml-allocated memory with g_free()
Don't assume that xmlFree() and g_free() are interchangeable, copy
the value returned from XML like we already do for other struct
members.
https://bugzilla.gnome.org/show_bug.cgi?id=781828
libgweather/gweather-location.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index 2a499a9..d2d70c8 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -165,7 +165,8 @@ location_new_from_xml (GWeatherParser *parser, GWeatherLocationLevel level,
if (!value)
goto error_out;
- loc->english_name = value;
+ loc->english_name = g_strdup (value);
+
if (loc->msgctxt) {
loc->local_name = g_strdup (g_dpgettext2 ("libgweather-locations",
(char*) loc->msgctxt, value));
@@ -180,6 +181,7 @@ location_new_from_xml (GWeatherParser *parser, GWeatherLocationLevel level,
normalized = g_utf8_normalize (loc->english_name, -1, G_NORMALIZE_ALL);
loc->english_sort_name = g_utf8_casefold (normalized, -1);
g_free (normalized);
+ xmlFree (value);
} else if (!strcmp (tagname, "iso-code") && !loc->country_code) {
value = _gweather_parser_get_value (parser);
if (!value)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]