From 6bbf2a57fcf33266c5859497f8cc32e1389a358a Mon Sep 17 00:00:00 2001 From: Feng Yu Date: Mon, 15 May 2023 02:24:15 -0700 Subject: vm: fix crash when setting __proto__ on context's globalThis PR-URL: https://github.com/nodejs/node/pull/47939 Reviewed-By: Zeyu "Alex" Yang Reviewed-By: James M Snell Reviewed-By: Darshan Sen Reviewed-By: Anna Henningsen --- test/parallel/test-vm-set-proto-null-on-globalthis.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/parallel/test-vm-set-proto-null-on-globalthis.js (limited to 'test') diff --git a/test/parallel/test-vm-set-proto-null-on-globalthis.js b/test/parallel/test-vm-set-proto-null-on-globalthis.js new file mode 100644 index 0000000000..869124fa86 --- /dev/null +++ b/test/parallel/test-vm-set-proto-null-on-globalthis.js @@ -0,0 +1,13 @@ +'use strict'; +require('../common'); + +// Setting __proto__ on vm context's globalThis should not cause a crash +// Regression test for https://github.com/nodejs/node/issues/47798 + +const vm = require('vm'); +const context = vm.createContext(); + +const contextGlobalThis = vm.runInContext('this', context); + +// Should not crash. +contextGlobalThis.__proto__ = null; // eslint-disable-line no-proto -- cgit v1.2.1