From b3cd3842b9ee68a80b0b3248f2912bce3e7f6253 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Apr 27 2017 11:41:24 +0000 Subject: Backport memory fixes Fix some dodgy memory handling that result in session crashes. --- diff --git a/backport-memory-fixes.patch b/backport-memory-fixes.patch new file mode 100644 index 0000000..475f53b --- /dev/null +++ b/backport-memory-fixes.patch @@ -0,0 +1,86 @@ +From 8cd4af9f34259de52bf25ecad27feb61927a0207 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Florian=20M=C3=BCllner?= +Date: Sun, 19 Mar 2017 17:25:11 +0100 +Subject: [PATCH 1/2] weather: Guard against segfault + +When GWeatherInfo:location is set to %NULL, the default location will +be used. Currently the code assumes that this fallback can always be +resolved, however find_by_station_code() may return %NULL, resulting +in a segfault. + +https://bugzilla.gnome.org/show_bug.cgi?id=780278 +--- + libgweather/gweather-weather.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/libgweather/gweather-weather.c b/libgweather/gweather-weather.c +index 87fb8fd..20b8c58 100644 +--- a/libgweather/gweather-weather.c ++++ b/libgweather/gweather-weather.c +@@ -2002,7 +2002,6 @@ gweather_info_set_location_internal (GWeatherInfo *info, + + if (priv->glocation) + gweather_location_unref (priv->glocation); +- _weather_location_free (&priv->location); + + priv->glocation = location; + +@@ -2023,8 +2022,12 @@ gweather_info_set_location_internal (GWeatherInfo *info, + priv->glocation = gweather_location_find_by_station_code (world, station_code); + } + +- _gweather_location_update_weather_location (priv->glocation, +- &priv->location); ++ if (priv->glocation) { ++ _weather_location_free (&priv->location); ++ _gweather_location_update_weather_location (priv->glocation, ++ &priv->location); ++ } ++ + if (name) { + g_free (priv->location.name); + priv->location.name = g_strdup (name); +-- +2.12.2 + + +From d40143d7091a0c0445d6687d79084f4b2c81e863 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Florian=20M=C3=BCllner?= +Date: Sat, 22 Apr 2017 04:30:37 +0200 +Subject: [PATCH 2/2] 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 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c +index ccbb8ee..31e236f 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) +-- +2.12.2 + diff --git a/libgweather.spec b/libgweather.spec index 1e5b4fb..bcdbf92 100644 --- a/libgweather.spec +++ b/libgweather.spec @@ -1,12 +1,14 @@ Name: libgweather Version: 3.24.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A library for weather information License: GPLv2+ URL: https://wiki.gnome.org/Projects/LibGWeather Source0: https://download.gnome.org/sources/libgweather/3.24/%{name}-%{version}.tar.xz +Patch1: backport-memory-fixes.patch + BuildRequires: pkgconfig(geocode-glib-1.0) BuildRequires: pkgconfig(gladeui-2.0) BuildRequires: pkgconfig(gobject-introspection-1.0) >= 0.10 @@ -36,6 +38,8 @@ developing applications that use %{name}. %prep %setup -q +%patch1 -p1 -b .backport-memory-fixes + %build %configure --disable-static --disable-gtk-doc make %{?_smp_mflags} @@ -86,6 +90,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &>/dev/null || : %changelog +* Thu Apr 27 2017 Florian Müllner - 3.24.0-2 +- Backport memory handling fixes + * Tue Mar 21 2017 Kalev Lember - 3.24.0-1 - Update to 3.24.0