[libgweather] weather: Guard against segfault
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather] weather: Guard against segfault
- Date: Mon, 20 Mar 2017 09:37:32 +0000 (UTC)
commit 61e09326f153f7eed78da21c70a5a97fd9be0390
Author: Florian Müllner <fmuellner gnome org>
Date: Sun Mar 19 17:25:11 2017 +0100
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 files 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]