trivial: Don't leak the string even on critical failure

Not totally sure this is worthwhile, but it triggered a failure in the
RHEL tests we do - and it's less work to fix it than argue.
This commit is contained in:
Richard Hughes 2022-03-08 14:21:47 +00:00
parent faac369d3a
commit 4ce9972ce5
3 changed files with 6 additions and 6 deletions

View File

@ -4567,7 +4567,7 @@ fwupd_client_set_user_agent_for_package(FwupdClient *self,
const gchar *package_version)
{
FwupdClientPrivate *priv = GET_PRIVATE(self);
GString *str = g_string_new(NULL);
g_autoptr(GString) str = g_string_new(NULL);
g_autofree gchar *system = NULL;
g_return_if_fail(FWUPD_IS_CLIENT(self));
@ -4588,7 +4588,7 @@ fwupd_client_set_user_agent_for_package(FwupdClient *self,
/* success */
g_free(priv->user_agent);
priv->user_agent = g_string_free(str, FALSE);
priv->user_agent = g_string_free(g_steal_pointer(&str), FALSE);
}
#ifdef HAVE_LIBCURL

View File

@ -308,7 +308,7 @@ fwupd_build_user_agent_system(void)
gchar *
fwupd_build_user_agent(const gchar *package_name, const gchar *package_version)
{
GString *str = g_string_new(NULL);
g_autoptr(GString) str = g_string_new(NULL);
g_autofree gchar *system = NULL;
g_return_val_if_fail(package_name != NULL, NULL);
@ -327,7 +327,7 @@ fwupd_build_user_agent(const gchar *package_name, const gchar *package_version)
g_string_append_printf(str, " fwupd/%s", PACKAGE_VERSION);
/* success */
return g_string_free(str, FALSE);
return g_string_free(g_steal_pointer(&str), FALSE);
}
/**

View File

@ -2833,7 +2833,7 @@ gchar *
fwupd_device_to_string(FwupdDevice *self)
{
FwupdDevicePrivate *priv = GET_PRIVATE(self);
GString *str = g_string_new(NULL);
g_autoptr(GString) str = g_string_new(NULL);
g_autoptr(GPtrArray) guid_helpers = NULL;
g_return_val_if_fail(FWUPD_IS_DEVICE(self), NULL);
@ -2950,7 +2950,7 @@ fwupd_device_to_string(FwupdDevice *self)
g_string_append_printf(str, " \n [%s]\n%s", FWUPD_RESULT_KEY_RELEASE, tmp);
}
return g_string_free(str, FALSE);
return g_string_free(g_steal_pointer(&str), FALSE);
}
static void