Backport some more memory handling fixes

This commit is contained in:
Adam Williamson 2017-05-24 09:16:16 -07:00
parent b3cd3842b9
commit 6decc46225
3 changed files with 100 additions and 4 deletions

View File

@ -0,0 +1,64 @@
From bbe6f7c1c85628336536bcec6684d281656a3739 Mon Sep 17 00:00:00 2001
From: Giovanni Campagna <gcampagna@src.gnome.org>
Date: Mon, 22 May 2017 08:39:45 -0700
Subject: [PATCH 1/2] Fix refcounting bug in GWeatherInfo
The return value of find_by_station_code() is transfer none, but
GWeatherInfo would take ownership of it.
---
libgweather/gweather-weather.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/libgweather/gweather-weather.c b/libgweather/gweather-weather.c
index 20b8c58..7d12b04 100644
--- a/libgweather/gweather-weather.c
+++ b/libgweather/gweather-weather.c
@@ -1992,7 +1992,7 @@ gweather_info_get_value_visibility (GWeatherInfo *info,
static void
gweather_info_set_location_internal (GWeatherInfo *info,
- GWeatherLocation *location)
+ GWeatherLocation *location)
{
GWeatherInfoPrivate *priv = info->priv;
GVariant *default_loc = NULL;
@@ -2000,26 +2000,31 @@ gweather_info_set_location_internal (GWeatherInfo *info,
gboolean latlon_override = FALSE;
gdouble lat, lon;
+ if (priv->glocation == location)
+ return;
+
if (priv->glocation)
gweather_location_unref (priv->glocation);
priv->glocation = location;
if (priv->glocation) {
- gweather_location_ref (location);
+ gweather_location_ref (location);
} else {
- GWeatherLocation *world;
- const gchar *station_code;
+ GWeatherLocation *world;
+ const gchar *station_code;
- default_loc = g_settings_get_value (priv->settings, DEFAULT_LOCATION);
+ default_loc = g_settings_get_value (priv->settings, DEFAULT_LOCATION);
- g_variant_get (default_loc, "(&s&sm(dd))", &name, &station_code, &latlon_override, &lat, &lon);
+ g_variant_get (default_loc, "(&s&sm(dd))", &name, &station_code, &latlon_override, &lat, &lon);
if (strcmp(name, "") == 0)
name = NULL;
world = gweather_location_get_world ();
priv->glocation = gweather_location_find_by_station_code (world, station_code);
+ if (priv->glocation)
+ gweather_location_ref (priv->glocation);
}
if (priv->glocation) {
--
2.13.0

View File

@ -0,0 +1,27 @@
From 5cd4fb5ad3344f8fe3c84b5c1872278bd7855ba7 Mon Sep 17 00:00:00 2001
From: Andreas Brauchli <andreas.brauchli@sensirion.com>
Date: Wed, 17 May 2017 22:29:05 +0200
Subject: [PATCH 2/2] Fix memory leak
* Free (gchar *) loc->yahoo_id from GWeatherLocation on unref()
https://bugzilla.gnome.org/show_bug.cgi?id=782760
---
libgweather/gweather-location.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index ccbb8ee..2a499a9 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -401,6 +401,7 @@ gweather_location_unref (GWeatherLocation *loc)
g_free (loc->tz_hint);
g_free (loc->station_code);
g_free (loc->forecast_zone);
+ g_free (loc->yahoo_id);
g_free (loc->radar);
if (loc->children) {
--
2.13.0

View File

@ -1,6 +1,6 @@
Name: libgweather
Version: 3.24.0
Release: 2%{?dist}
Release: 3%{?dist}
Summary: A library for weather information
License: GPLv2+
@ -8,6 +8,10 @@ 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
# https://git.gnome.org/browse/libgweather/commit/?id=bbe6f7c1c85628336536bcec6684d281656a3739
Patch2: 0001-Fix-refcounting-bug-in-GWeatherInfo.patch
# https://git.gnome.org/browse/libgweather/commit/?id=5cd4fb5ad3344f8fe3c84b5c1872278bd7855ba7
Patch3: 0002-Fix-memory-leak.patch
BuildRequires: pkgconfig(geocode-glib-1.0)
BuildRequires: pkgconfig(gladeui-2.0)
@ -36,9 +40,7 @@ developing applications that use %{name}.
%prep
%setup -q
%patch1 -p1 -b .backport-memory-fixes
%autosetup -p1
%build
%configure --disable-static --disable-gtk-doc
@ -90,6 +92,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &>/dev/null || :
%changelog
* Wed May 24 2017 Adam Williamson <awilliam@redhat.com> - 3.24.0-3
- Backport some more memory handling fixes
* Thu Apr 27 2017 Florian Müllner <fmuellner@redhat.com> - 3.24.0-2
- Backport memory handling fixes