aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-06-05 17:17:35 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-06-05 17:17:48 -0700
commit0c11762c310c2655fe5c3ecc60671c93934abdc3 (patch)
tree6fc2b4bbf658ee5fd2d5c62933f6f1ff411d026a /src
parentfe7d5357d8b025c671944705047338c1aa26be4a (diff)
downloadbun-0c11762c310c2655fe5c3ecc60671c93934abdc3.tar.gz
bun-0c11762c310c2655fe5c3ecc60671c93934abdc3.tar.zst
bun-0c11762c310c2655fe5c3ecc60671c93934abdc3.zip
[node:vm] Fix crash when `new ArrayBuffer()` is returned
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/bindings/webcore/WebCoreTypedArrayController.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/bun.js/bindings/webcore/WebCoreTypedArrayController.cpp b/src/bun.js/bindings/webcore/WebCoreTypedArrayController.cpp
index 4c9660e26..ca8c79aef 100644
--- a/src/bun.js/bindings/webcore/WebCoreTypedArrayController.cpp
+++ b/src/bun.js/bindings/webcore/WebCoreTypedArrayController.cpp
@@ -51,6 +51,10 @@ JSC::JSArrayBuffer* WebCoreTypedArrayController::toJS(JSC::JSGlobalObject* lexic
void WebCoreTypedArrayController::registerWrapper(JSC::JSGlobalObject* globalObject, JSC::ArrayBuffer* native, JSC::JSArrayBuffer* wrapper)
{
+ // require("vm") can be used to create an ArrayBuffer
+ if (UNLIKELY(!globalObject->inherits<JSDOMGlobalObject>()))
+ return;
+
cacheWrapper(JSC::jsCast<JSDOMGlobalObject*>(globalObject)->world(), native, wrapper);
}