ocaml/guestfs-c.c: Avoid bogus -fanalyzer warning

This warning is bogus, caused by the analyzer cannot track that len ==
0 if roots == NULL.  I just changed the code to make it easier to
analyze, this doesn't fix any real bug.

guestfs-c.c: In function 'guestfs_finalize':
guestfs-c.c:85:9: error: dereference of NULL '0B' [CWE-476] [-Werror=analyzer-null-dereference]
   85 |         caml_remove_generational_global_root (roots[i]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
Richard W.M. Jones
2021-09-07 16:44:14 +01:00
parent a7245fba7a
commit ea04d6b878

View File

@@ -79,7 +79,7 @@ guestfs_finalize (value gv)
guestfs_close (g);
/* Now unregister the global roots. */
if (len > 0) {
if (roots && len > 0) {
size_t i;
for (i = 0; i < len; ++i) {
caml_remove_generational_global_root (roots[i]);