Skip to content

Commit

Permalink
avoid access after free in returnvalue test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kkoopa committed Oct 10, 2024
1 parent ab25f99 commit affc05a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions test/cpp/returnvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ NAN_METHOD(ReturnPrimitive) {

NAN_METHOD(ReturnGlobal) {
info.GetReturnValue().Set(global);
global.Reset();
}

NAN_METHOD(ReturnUnsigned) {
Expand Down

0 comments on commit affc05a

Please sign in to comment.