From affc05a6ea08c7be6773a4a06a89e415de0497e1 Mon Sep 17 00:00:00 2001 From: Benjamin Byholm Date: Thu, 10 Oct 2024 03:35:23 +0300 Subject: [PATCH] avoid access after free in returnvalue test The isolate can be Disposed due to the test finishing before the destructor of the static Global fires. Resetting said Global avoids this possibility. The point of the test is to verify that returning a Global is possible, not that this interaction of Global's destructor and Node shutting down is safe. --- test/cpp/returnvalue.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cpp/returnvalue.cpp b/test/cpp/returnvalue.cpp index 31e551ab..12017a22 100644 --- a/test/cpp/returnvalue.cpp +++ b/test/cpp/returnvalue.cpp @@ -28,6 +28,7 @@ NAN_METHOD(ReturnPrimitive) { NAN_METHOD(ReturnGlobal) { info.GetReturnValue().Set(global); + global.Reset(); } NAN_METHOD(ReturnUnsigned) {