Skip to content

Commit 440dcd7

Browse files
committed
fix crash
1 parent ee1dacf commit 440dcd7

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/node_messaging.cc

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,7 @@ class DeserializerDelegate : public ValueDeserializer::Delegate {
139139
if (!deserializer->ReadUint32(&id))
140140
return MaybeLocal<Object>();
141141

142-
EscapableHandleScope scope(isolate);
143-
Local<Context> context = isolate->GetCurrentContext();
144-
if (id == kDOMExceptionTag) {
145-
return ReadDOMException(isolate, context, deserializer);
146-
}
147-
148-
if (id != kNormalObject) {
142+
if (id != kNormalObject && id != kDOMExceptionTag) {
149143
CHECK_LT(id, host_objects_.size());
150144
Local<Object> object = host_objects_[id]->object(isolate);
151145
if (env_->js_transferable_constructor_template()->HasInstance(object)) {
@@ -154,6 +148,12 @@ class DeserializerDelegate : public ValueDeserializer::Delegate {
154148
return object;
155149
}
156150
}
151+
152+
EscapableHandleScope scope(isolate);
153+
Local<Context> context = isolate->GetCurrentContext();
154+
if (id == kDOMExceptionTag) {
155+
return ReadDOMException(isolate, context, deserializer);
156+
}
157157
Local<Value> object;
158158
if (!deserializer->ReadValue(context).ToLocal(&object))
159159
return MaybeLocal<Object>();
@@ -424,21 +424,11 @@ Maybe<bool> IsDOMException(Isolate* isolate,
424424
Local<Object> obj) {
425425
HandleScope handle_scope(isolate);
426426

427-
Local<Object> per_context_bindings;
428427
Local<Value> dom_exception_ctor_val;
429-
430-
if (!GetPerContextExports(context).ToLocal(&per_context_bindings)) {
428+
if (!GetDOMException(context).ToLocal(&dom_exception_ctor_val)) {
431429
return Just(false);
432430
}
433431

434-
if (!per_context_bindings
435-
->Get(context,
436-
FIXED_ONE_BYTE_STRING(isolate, "DOMException"))
437-
.ToLocal(&dom_exception_ctor_val) ||
438-
!dom_exception_ctor_val->IsFunction()) {
439-
return Nothing<bool>();
440-
}
441-
442432
Local<Function> dom_exception_ctor = dom_exception_ctor_val.As<Function>();
443433
Local<Value> obj_constructor;
444434
if (!obj->Get(context, FIXED_ONE_BYTE_STRING(isolate, "constructor"))

test/parallel/test-structuredClone-global.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ for (const Transferrable of [File, Blob]) {
104104

105105
{
106106
const obj = {};
107-
obj.setPrototypeOf(DOMException.prototype);
107+
Object.setPrototypeOf(obj, DOMException.prototype);
108108
const clone = structuredClone(obj);
109109
assert.strictEqual(clone instanceof DOMException, false);
110110
}

0 commit comments

Comments
 (0)