gweather_location_get_name() may leak memory
/**
* gweather_location_get_name:
* @loc: a #GWeatherLocation
*
* Gets @loc's name, localized into the current language.
*
* Return value: @loc's name
**/
const char *
gweather_location_get_name (GWeatherLocation *loc)
{
g_return_val_if_fail (loc != NULL, NULL);
return g_strdup (loc->local_name);
}
/**
* gweather_location_get_sort_name:
* @loc: a #GWeatherLocation
*
* Gets @loc's "sort name", which is the name after having
* g_utf8_normalize() (with %G_NORMALIZE_ALL) and g_utf8_casefold()
* called on it. You can use this to sort locations, or to comparing
* user input against a location name.
*
* Return value: @loc's sort name
**/
const char *
gweather_location_get_sort_name (GWeatherLocation *loc)
{
g_return_val_if_fail (loc != NULL, NULL);
return loc->local_sort_name;
}
gweather_location_get_name()
returns a newly allocated string, but both the prototype and the documentation present it as an unowned string, which hence could cause leaks. We can see this doesn't match the behavior of other methods like gweather_location_get_sort_name()
.
Is there a reason for duplicating the string or is that an issue?
Edited by Adrien Plazas