mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
ocaml: Nullify custom block before releasing runtime lock
Avoids a potential, though if possible then very rare, double free path. Suggested-by: Guillaume Munch-Maccagnoni See: https://github.com/ocaml/ocaml/issues/12820
This commit is contained in:
@@ -156,6 +156,9 @@ guestfs_int_ocaml_close (value gv)
|
||||
size_t len;
|
||||
value **roots = get_all_event_callbacks (g, &len);
|
||||
|
||||
/* So we don't double-free. */
|
||||
Guestfs_val (gv) = NULL;
|
||||
|
||||
/* Close the handle: this could invoke callbacks from the list
|
||||
* above, which is why we don't want to delete them before
|
||||
* closing the handle.
|
||||
@@ -173,9 +176,6 @@ guestfs_int_ocaml_close (value gv)
|
||||
}
|
||||
free (roots);
|
||||
}
|
||||
|
||||
/* So we don't double-free. */
|
||||
Guestfs_val (gv) = NULL;
|
||||
}
|
||||
|
||||
CAMLreturn (Val_unit);
|
||||
|
||||
Reference in New Issue
Block a user