trivial: Fix a few theoretical memory leaks that can't happen in reality

PVS: The function was exited without releasing the 'str' pointer.
This commit is contained in:
Richard Hughes 2022-09-09 11:05:28 +01:00
parent e84e8b6927
commit aa71485cc5
3 changed files with 10 additions and 12 deletions

View File

@ -204,7 +204,7 @@ fu_security_attrs_calculate_hsi(FuSecurityAttrs *self, FuSecurityAttrsFlags flag
{
guint hsi_number = 0;
FwupdSecurityAttrFlags attr_flags = FWUPD_SECURITY_ATTR_FLAG_NONE;
GString *str = g_string_new("HSI:");
g_autoptr(GString) str = g_string_new("HSI:");
const FwupdSecurityAttrFlags hpi_suffixes[] = {
FWUPD_SECURITY_ATTR_FLAG_RUNTIME_ISSUE,
FWUPD_SECURITY_ATTR_FLAG_NONE,
@ -247,10 +247,8 @@ fu_security_attrs_calculate_hsi(FuSecurityAttrs *self, FuSecurityAttrsFlags flag
if (fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_RUNTIME_ISSUE) &&
fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_SUCCESS))
continue;
if (fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_MISSING_DATA)) {
g_string_append(str, "INVALID:missing-data");
return g_string_free(str, FALSE);
}
if (fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_MISSING_DATA))
return g_strdup("HSI:INVALID:missing-data");
attr_flags |= fwupd_security_attr_get_flags(attr);
}
@ -273,7 +271,7 @@ fu_security_attrs_calculate_hsi(FuSecurityAttrs *self, FuSecurityAttrsFlags flag
FWUPD_MICRO_VERSION);
}
return g_string_free(str, FALSE);
return g_string_free(g_steal_pointer(&str), FALSE);
}
static gchar *

View File

@ -14,10 +14,10 @@
static gchar *
fu_logitech_hidpp_msg_to_string(FuLogitechHidPpHidppMsg *msg)
{
GString *str = g_string_new(NULL);
const gchar *tmp;
g_autoptr(GError) error = NULL;
g_autoptr(GString) flags_str = g_string_new(NULL);
g_autoptr(GString) str = g_string_new(NULL);
g_return_val_if_fail(msg != NULL, NULL);
@ -53,7 +53,7 @@ fu_logitech_hidpp_msg_to_string(FuLogitechHidPpHidppMsg *msg)
if (!fu_logitech_hidpp_msg_is_error(msg, &error)) {
g_string_append_printf(str, "error: %s\n", error->message);
}
return g_string_free(str, FALSE);
return g_string_free(g_steal_pointer(&str), FALSE);
}
gboolean

View File

@ -1862,9 +1862,9 @@ fu_util_release_to_string(FwupdRelease *rel, guint idt)
const gchar *tmp2;
GPtrArray *issues = fwupd_release_get_issues(rel);
GPtrArray *tags = fwupd_release_get_tags(rel);
GString *str = g_string_new(NULL);
guint64 flags = fwupd_release_get_flags(rel);
g_autofree gchar *desc_fb = NULL;
g_autoptr(GString) str = g_string_new(NULL);
g_return_val_if_fail(FWUPD_IS_RELEASE(rel), NULL);
@ -2022,17 +2022,17 @@ fu_util_release_to_string(FwupdRelease *rel, guint idt)
tag_strs);
}
return g_string_free(str, FALSE);
return g_string_free(g_steal_pointer(&str), FALSE);
}
gchar *
fu_util_remote_to_string(FwupdRemote *remote, guint idt)
{
GString *str = g_string_new(NULL);
FwupdRemoteKind kind = fwupd_remote_get_kind(remote);
FwupdKeyringKind keyring_kind = fwupd_remote_get_keyring_kind(remote);
const gchar *tmp;
gint priority;
g_autoptr(GString) str = g_string_new(NULL);
g_return_val_if_fail(FWUPD_IS_REMOTE(remote), NULL);
@ -2149,7 +2149,7 @@ fu_util_remote_to_string(FwupdRemote *remote, guint idt)
fwupd_remote_get_automatic_reports(remote) ? "true" : "false");
}
return g_string_free(str, FALSE);
return g_string_free(g_steal_pointer(&str), FALSE);
}
static void