uf2: Fix a small memory leak when parsing files

Fixes https://oss-fuzz.com/testcase-detail/4617823934087168
This commit is contained in:
Richard Hughes 2022-08-30 16:39:39 +01:00
parent bdfe66a16e
commit 6fd7a62efe

View File

@ -239,6 +239,7 @@ fu_uf2_firmware_parse(FuFirmware *firmware,
{
FuUf2Firmware *self = FU_UF2_FIRMWARE(firmware);
g_autoptr(GByteArray) tmp = g_byte_array_new();
g_autoptr(GBytes) blob = NULL;
g_autoptr(GPtrArray) chunks = NULL;
/* read in fixed sized chunks */
@ -250,7 +251,8 @@ fu_uf2_firmware_parse(FuFirmware *firmware,
}
/* success */
fu_firmware_set_bytes(firmware, g_byte_array_free_to_bytes(g_steal_pointer(&tmp)));
blob = g_byte_array_free_to_bytes(g_steal_pointer(&tmp));
fu_firmware_set_bytes(firmware, blob);
return TRUE;
}