From 5b418307730712ac767944075a47839c4ee1296f Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 14 Jan 2021 17:23:46 -0300 Subject: location: Fix double frees 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. --- libgweather/gweather-location.c | 6 +++--- 1 file 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); } } -- cgit v1.2.1