mirror of
https://git.proxmox.com/git/fwupd
synced 2025-06-12 06:48:57 +00:00
tpm: Fix a small memory leak in an error path
This commit is contained in:
parent
b25a3a4294
commit
db07e84fe0
@ -45,6 +45,8 @@ fu_tpm_eventlog_parser_item_free(FuTpmEventlogItem *item)
|
|||||||
g_free(item);
|
g_free(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(FuTpmEventlogItem, fu_tpm_eventlog_parser_item_free);
|
||||||
|
|
||||||
void
|
void
|
||||||
fu_tpm_eventlog_item_to_string(FuTpmEventlogItem *item, guint idt, GString *str)
|
fu_tpm_eventlog_item_to_string(FuTpmEventlogItem *item, guint idt, GString *str)
|
||||||
{
|
{
|
||||||
@ -186,7 +188,7 @@ fu_tpm_eventlog_parser_parse_blob_v2(const guint8 *buf,
|
|||||||
/* save blob if PCR=0 */
|
/* save blob if PCR=0 */
|
||||||
idx += sizeof(datasz);
|
idx += sizeof(datasz);
|
||||||
if (pcr == ESYS_TR_PCR0 || flags & FU_TPM_EVENTLOG_PARSER_FLAG_ALL_PCRS) {
|
if (pcr == ESYS_TR_PCR0 || flags & FU_TPM_EVENTLOG_PARSER_FLAG_ALL_PCRS) {
|
||||||
FuTpmEventlogItem *item;
|
g_autoptr(FuTpmEventlogItem) item = NULL;
|
||||||
|
|
||||||
/* build item */
|
/* build item */
|
||||||
item = g_new0(FuTpmEventlogItem, 1);
|
item = g_new0(FuTpmEventlogItem, 1);
|
||||||
@ -209,7 +211,7 @@ fu_tpm_eventlog_parser_parse_blob_v2(const guint8 *buf,
|
|||||||
if (g_getenv("FWUPD_TPM_EVENTLOG_VERBOSE") != NULL)
|
if (g_getenv("FWUPD_TPM_EVENTLOG_VERBOSE") != NULL)
|
||||||
fu_common_dump_bytes(G_LOG_DOMAIN, "TpmEvent", item->blob);
|
fu_common_dump_bytes(G_LOG_DOMAIN, "TpmEvent", item->blob);
|
||||||
}
|
}
|
||||||
g_ptr_array_add(items, item);
|
g_ptr_array_add(items, g_steal_pointer(&item));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* next entry */
|
/* next entry */
|
||||||
@ -279,7 +281,7 @@ fu_tpm_eventlog_parser_new(const guint8 *buf,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (pcr == ESYS_TR_PCR0 || flags & FU_TPM_EVENTLOG_PARSER_FLAG_ALL_PCRS) {
|
if (pcr == ESYS_TR_PCR0 || flags & FU_TPM_EVENTLOG_PARSER_FLAG_ALL_PCRS) {
|
||||||
FuTpmEventlogItem *item;
|
g_autoptr(FuTpmEventlogItem) item = NULL;
|
||||||
guint8 digest[TPM2_SHA1_DIGEST_SIZE] = {0x0};
|
guint8 digest[TPM2_SHA1_DIGEST_SIZE] = {0x0};
|
||||||
|
|
||||||
/* copy hash */
|
/* copy hash */
|
||||||
@ -313,7 +315,7 @@ fu_tpm_eventlog_parser_new(const guint8 *buf,
|
|||||||
if (g_getenv("FWUPD_TPM_EVENTLOG_VERBOSE") != NULL)
|
if (g_getenv("FWUPD_TPM_EVENTLOG_VERBOSE") != NULL)
|
||||||
fu_common_dump_bytes(G_LOG_DOMAIN, "TpmEvent", item->blob);
|
fu_common_dump_bytes(G_LOG_DOMAIN, "TpmEvent", item->blob);
|
||||||
}
|
}
|
||||||
g_ptr_array_add(items, item);
|
g_ptr_array_add(items, g_steal_pointer(&item));
|
||||||
}
|
}
|
||||||
idx += datasz;
|
idx += datasz;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user