summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2021-01-14 17:23:46 -0300
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2021-01-14 17:23:46 -0300
commit5b418307730712ac767944075a47839c4ee1296f (patch)
treea3d5ff7b0967917f68c56f6a17b8f2b48a34973f
parent1ebc7399c3d77265ea0cfc88e23b8e9a26b5b0f8 (diff)
downloadlibgweather-gbsneto/fix-refs.tar.gz
location: Fix double freesgbsneto/fix-refs
The 'nearest_station' argument of _gweather_location_new_detached() is transfer-none, which means a ref must be increased when passing this parameter. However, in various locations, g_autoptr was referencing the passed 'nearest_station', which would cause double-frees down the line. Fix these double-frees by stealing the 'nearest_location' ref when passing it to _gweather_location_new_detached() when under g_autoptr.
-rw-r--r--libgweather/gweather-location.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index d29959f..c15e119 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -1623,7 +1623,7 @@ gweather_location_common_deserialize (GWeatherLocation *world,
*/
if (!latlon_valid)
return by_station_code
- ? _gweather_location_new_detached (by_station_code,
+ ? _gweather_location_new_detached (g_steal_pointer (&by_station_code),
name, FALSE, 0, 0)
: NULL;
@@ -1679,7 +1679,7 @@ gweather_location_common_deserialize (GWeatherLocation *world,
/* No weather station matches the serialized data, let's pick
one at random from the station code list */
if (by_station_code)
- return _gweather_location_new_detached (by_station_code,
+ return _gweather_location_new_detached (g_steal_pointer (&by_station_code),
name, TRUE, latitude, longitude);
else
return NULL;
@@ -1857,7 +1857,7 @@ gweather_location_new_detached (const char *name,
latitude = DEGREES_TO_RADIANS (latitude);
longitude = DEGREES_TO_RADIANS (longitude);
- return _gweather_location_new_detached (city, name,
+ return _gweather_location_new_detached (g_steal_pointer (&city), name,
TRUE, latitude, longitude);
}
}