38 lines
985 B
Diff
38 lines
985 B
Diff
From 37997f7e9a694715c764528567e569812fa3066a Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Thu, 14 Dec 2023 08:34:56 +0000
|
|
Subject: [PATCH 2/2] 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
|
|
---
|
|
ocaml/handle.c | 6 +++---
|
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/ocaml/handle.c b/ocaml/handle.c
|
|
index 0e809c6f0d..8d8a632fef 100644
|
|
--- a/ocaml/handle.c
|
|
+++ b/ocaml/handle.c
|
|
@@ -54,12 +54,12 @@ nbd_internal_ocaml_nbd_close (value hv)
|
|
struct nbd_handle *h = NBD_val (hv);
|
|
|
|
if (h) {
|
|
+ /* So we don't double-free. */
|
|
+ NBD_val (hv) = NULL;
|
|
+
|
|
caml_enter_blocking_section ();
|
|
nbd_close (h);
|
|
caml_leave_blocking_section ();
|
|
-
|
|
- /* So we don't double-free. */
|
|
- NBD_val (hv) = NULL;
|
|
}
|
|
|
|
CAMLreturn (Val_unit);
|
|
--
|
|
2.43.0
|
|
|