summaryrefslogtreecommitdiff
path: root/src/libostree
diff options
context:
space:
mode:
authorLuca BRUNO <luca.bruno@coreos.com>2022-09-08 13:53:05 +0000
committerLuca BRUNO <luca.bruno@coreos.com>2022-09-08 13:53:05 +0000
commit542b79cfeb3d6475f759ebd633cce91422d531ec (patch)
treeebff897cbb022a0ac5abc69a57a7fd427ef0a584 /src/libostree
parent6873a2511b21a0ba3d5ca80a24f0047e0079b46e (diff)
downloadostree-542b79cfeb3d6475f759ebd633cce91422d531ec.tar.gz
otutil: add error handling to variant builders
This enhances a bunch of helpers related to GVariant building, in order to properly handle errors and avoid some potential cases of unexpected NULL results.
Diffstat (limited to 'src/libostree')
-rw-r--r--src/libostree/ostree-repo-static-delta-compilation.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c
index cf232c11..28b42139 100644
--- a/src/libostree/ostree-repo-static-delta-compilation.c
+++ b/src/libostree/ostree-repo-static-delta-compilation.c
@@ -1369,7 +1369,6 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
g_autoptr(GPtrArray) builder_parts = g_ptr_array_new_with_free_func ((GDestroyNotify)ostree_static_delta_part_builder_unref);
g_autoptr(GPtrArray) builder_fallback_objects = g_ptr_array_new_with_free_func ((GDestroyNotify)g_variant_unref);
g_auto(GLnxTmpfile) descriptor_tmpf = { 0, };
- g_autoptr(OtVariantBuilder) descriptor_builder = NULL;
const char *opt_sign_name;
const char **opt_key_ids;
@@ -1456,7 +1455,10 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
&descriptor_tmpf, error))
return FALSE;
- descriptor_builder = ot_variant_builder_new (G_VARIANT_TYPE (OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT), descriptor_tmpf.fd);
+ g_autoptr(OtVariantBuilder) descriptor_builder =
+ ot_variant_builder_new (G_VARIANT_TYPE (OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT),
+ descriptor_tmpf.fd);
+ g_assert (descriptor_builder != NULL);
/* Open the metadata dict */
if (!ot_variant_builder_open (descriptor_builder, G_VARIANT_TYPE ("a{sv}"), error))
@@ -1603,7 +1605,6 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
const gchar *signature_key = NULL;
g_autoptr(GVariantBuilder) signature_builder = NULL;
g_auto(GLnxTmpfile) descriptor_sign_tmpf = { 0, };
- g_autoptr(OtVariantBuilder) descriptor_sign_builder = NULL;
lseek (descriptor_tmpf.fd, 0, SEEK_SET);
tmpdata = glnx_fd_readall_bytes (descriptor_tmpf.fd, cancellable, error);
@@ -1640,8 +1641,10 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
&descriptor_sign_tmpf, error))
return FALSE;
- descriptor_sign_builder = ot_variant_builder_new (G_VARIANT_TYPE (OSTREE_STATIC_DELTA_SIGNED_FORMAT),
- descriptor_sign_tmpf.fd);
+ g_autoptr(OtVariantBuilder) descriptor_sign_builder =
+ ot_variant_builder_new (G_VARIANT_TYPE (OSTREE_STATIC_DELTA_SIGNED_FORMAT),
+ descriptor_sign_tmpf.fd);
+ g_assert (descriptor_sign_builder != NULL);
if (!ot_variant_builder_add (descriptor_sign_builder, error, "t",
GUINT64_TO_BE (OSTREE_STATIC_DELTA_SIGNED_MAGIC)))