From: Colin Walters Date: Tue, 29 Aug 2023 14:09:25 +0000 (-0400) Subject: mutable-tree: Quiet clang-analyzer warning X-Git-Tag: archive/raspbian/2023.7-3+rpi1^2~16^2^2~37^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=db4ca6e7acfb9e62764a3c1c006c49e13e225e7b;p=ostree.git mutable-tree: Quiet clang-analyzer warning The warning here was about a use-after-free which is serious, but I don't think it was reachable in practice, because we'd only enter the second conditional if `contents_checksum != self->contents_checksum`, yet we made them the same thing here. Nevertheless, refactor the code to do a direct return in this case because that's basically what happened before, and doing so is a lot clearer. --- diff --git a/src/libostree/ostree-mutable-tree.c b/src/libostree/ostree-mutable-tree.c index 2d52e402..c1da04d8 100644 --- a/src/libostree/ostree-mutable-tree.c +++ b/src/libostree/ostree-mutable-tree.c @@ -505,8 +505,9 @@ ostree_mutable_tree_fill_empty_from_dirtree (OstreeMutableTree *self, OstreeRepo if (g_strcmp0 (empty_tree_csum, contents_checksum) == 0) { /* Adding an empty tree to a full one - stick with the old contents */ - contents_checksum = self->contents_checksum; - break; + g_set_object (&self->repo, repo); + ostree_mutable_tree_set_metadata_checksum (self, metadata_checksum); + return TRUE; } else return FALSE;