[libgweather/gbsneto/fix-refs] location: Fix double frees
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather/gbsneto/fix-refs] location: Fix double frees
- Date: Thu, 14 Jan 2021 20:29:03 +0000 (UTC)
commit 5b418307730712ac767944075a47839c4ee1296f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Jan 14 17:23:46 2021 -0300
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 d29959fe..c15e1190 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);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]