mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-14 12:35:57 +00:00
trivial: Fix a small memory leak in the self tests
This commit is contained in:
parent
6a2d222eea
commit
7453d59ccf
@ -1057,7 +1057,8 @@ static void
|
|||||||
fu_common_cabinet_func(void)
|
fu_common_cabinet_func(void)
|
||||||
{
|
{
|
||||||
g_autoptr(FuCabinet) cabinet = fu_cabinet_new();
|
g_autoptr(FuCabinet) cabinet = fu_cabinet_new();
|
||||||
g_autoptr(GBytes) blob = NULL;
|
g_autoptr(GBytes) blob1 = NULL;
|
||||||
|
g_autoptr(GBytes) blob2 = NULL;
|
||||||
g_autoptr(GBytes) jcat_blob1 = g_bytes_new_static("hello", 6);
|
g_autoptr(GBytes) jcat_blob1 = g_bytes_new_static("hello", 6);
|
||||||
g_autoptr(GBytes) jcat_blob2 = g_bytes_new_static("hellX", 6);
|
g_autoptr(GBytes) jcat_blob2 = g_bytes_new_static("hellX", 6);
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
@ -1069,15 +1070,15 @@ fu_common_cabinet_func(void)
|
|||||||
fu_cabinet_add_file(cabinet, "firmware.jcat", jcat_blob2);
|
fu_cabinet_add_file(cabinet, "firmware.jcat", jcat_blob2);
|
||||||
|
|
||||||
/* get data */
|
/* get data */
|
||||||
blob = fu_cabinet_get_file(cabinet, "firmware.jcat", &error);
|
blob1 = fu_cabinet_get_file(cabinet, "firmware.jcat", &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_nonnull(blob);
|
g_assert_nonnull(blob1);
|
||||||
g_assert_cmpstr(g_bytes_get_data(blob, NULL), ==, "hellX");
|
g_assert_cmpstr(g_bytes_get_data(blob1, NULL), ==, "hellX");
|
||||||
|
|
||||||
/* get data that does not exist */
|
/* get data that does not exist */
|
||||||
blob = fu_cabinet_get_file(cabinet, "foo.jcat", &error);
|
blob2 = fu_cabinet_get_file(cabinet, "foo.jcat", &error);
|
||||||
g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE);
|
g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE);
|
||||||
g_assert_null(blob);
|
g_assert_null(blob2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1160,12 +1161,15 @@ fu_common_store_cab_func(void)
|
|||||||
static void
|
static void
|
||||||
fu_common_store_cab_artifact_func(void)
|
fu_common_store_cab_artifact_func(void)
|
||||||
{
|
{
|
||||||
g_autoptr(GBytes) blob = NULL;
|
g_autoptr(GBytes) blob1 = NULL;
|
||||||
|
g_autoptr(GBytes) blob2 = NULL;
|
||||||
|
g_autoptr(GBytes) blob3 = NULL;
|
||||||
|
g_autoptr(GBytes) blob4 = NULL;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(XbSilo) silo = NULL;
|
g_autoptr(XbSilo) silo = NULL;
|
||||||
|
|
||||||
/* create silo (sha256, using artifacts object) */
|
/* create silo (sha256, using artifacts object) */
|
||||||
blob = _build_cab(
|
blob1 = _build_cab(
|
||||||
GCAB_COMPRESSION_NONE,
|
GCAB_COMPRESSION_NONE,
|
||||||
"acme.metainfo.xml",
|
"acme.metainfo.xml",
|
||||||
"<component type=\"firmware\">\n"
|
"<component type=\"firmware\">\n"
|
||||||
@ -1188,13 +1192,13 @@ fu_common_store_cab_artifact_func(void)
|
|||||||
"firmware.dfu.asc",
|
"firmware.dfu.asc",
|
||||||
"signature",
|
"signature",
|
||||||
NULL);
|
NULL);
|
||||||
silo = fu_common_cab_build_silo(blob, 10240, &error);
|
silo = fu_common_cab_build_silo(blob1, 10240, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_nonnull(silo);
|
g_assert_nonnull(silo);
|
||||||
g_clear_object(&silo);
|
g_clear_object(&silo);
|
||||||
|
|
||||||
/* create silo (sha1, using artifacts object; mixed case) */
|
/* create silo (sha1, using artifacts object; mixed case) */
|
||||||
blob = _build_cab(GCAB_COMPRESSION_NONE,
|
blob2 = _build_cab(GCAB_COMPRESSION_NONE,
|
||||||
"acme.metainfo.xml",
|
"acme.metainfo.xml",
|
||||||
"<component type=\"firmware\">\n"
|
"<component type=\"firmware\">\n"
|
||||||
" <id>com.acme.example.firmware</id>\n"
|
" <id>com.acme.example.firmware</id>\n"
|
||||||
@ -1216,13 +1220,14 @@ fu_common_store_cab_artifact_func(void)
|
|||||||
"firmware.dfu.asc",
|
"firmware.dfu.asc",
|
||||||
"signature",
|
"signature",
|
||||||
NULL);
|
NULL);
|
||||||
silo = fu_common_cab_build_silo(blob, 10240, &error);
|
silo = fu_common_cab_build_silo(blob2, 10240, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_nonnull(silo);
|
g_assert_nonnull(silo);
|
||||||
g_clear_object(&silo);
|
g_clear_object(&silo);
|
||||||
|
|
||||||
/* create silo (sha512, using artifacts object; lower case) */
|
/* create silo (sha512, using artifacts object; lower case) */
|
||||||
blob = _build_cab(GCAB_COMPRESSION_NONE,
|
blob3 =
|
||||||
|
_build_cab(GCAB_COMPRESSION_NONE,
|
||||||
"acme.metainfo.xml",
|
"acme.metainfo.xml",
|
||||||
"<component type=\"firmware\">\n"
|
"<component type=\"firmware\">\n"
|
||||||
" <id>com.acme.example.firmware</id>\n"
|
" <id>com.acme.example.firmware</id>\n"
|
||||||
@ -1246,13 +1251,13 @@ fu_common_store_cab_artifact_func(void)
|
|||||||
"firmware.dfu.asc",
|
"firmware.dfu.asc",
|
||||||
"signature",
|
"signature",
|
||||||
NULL);
|
NULL);
|
||||||
silo = fu_common_cab_build_silo(blob, 10240, &error);
|
silo = fu_common_cab_build_silo(blob3, 10240, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_nonnull(silo);
|
g_assert_nonnull(silo);
|
||||||
g_clear_object(&silo);
|
g_clear_object(&silo);
|
||||||
|
|
||||||
/* create silo (legacy release object) */
|
/* create silo (legacy release object) */
|
||||||
blob = _build_cab(GCAB_COMPRESSION_NONE,
|
blob4 = _build_cab(GCAB_COMPRESSION_NONE,
|
||||||
"acme.metainfo.xml",
|
"acme.metainfo.xml",
|
||||||
"<component type=\"firmware\">\n"
|
"<component type=\"firmware\">\n"
|
||||||
" <id>com.acme.example.firmware</id>\n"
|
" <id>com.acme.example.firmware</id>\n"
|
||||||
@ -1271,7 +1276,7 @@ fu_common_store_cab_artifact_func(void)
|
|||||||
"firmware.dfu.asc",
|
"firmware.dfu.asc",
|
||||||
"signature",
|
"signature",
|
||||||
NULL);
|
NULL);
|
||||||
silo = fu_common_cab_build_silo(blob, 10240, &error);
|
silo = fu_common_cab_build_silo(blob4, 10240, &error);
|
||||||
g_assert_no_error(error);
|
g_assert_no_error(error);
|
||||||
g_assert_nonnull(silo);
|
g_assert_nonnull(silo);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user