0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-25 15:29:43 -05:00

Throw DataCloneError if SAB cannot be cloned (#781)

Best case, it produces serialized output that cannot be deserialized.

Worst case, it hits this assert in V8:

    # Fatal error in v8::FromJust
    # Maybe value is Nothing.
This commit is contained in:
Ben Noordhuis 2021-09-18 15:21:04 +02:00 committed by GitHub
parent 0bdeb0c5c4
commit 09347d32c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -2551,8 +2551,11 @@ struct v8__ValueSerializer__Delegate : public v8::ValueSerializer::Delegate {
v8::Local<v8::SharedArrayBuffer> shared_array_buffer) override {
uint32_t result = 0;
if (!v8__ValueSerializer__Delegate__GetSharedArrayBufferId(
this, isolate, shared_array_buffer, &result))
return v8::Nothing<uint32_t>();
this, isolate, shared_array_buffer, &result)) {
// Forward to the original method. It'll throw DataCloneError.
return v8::ValueSerializer::Delegate::GetSharedArrayBufferId(
isolate, shared_array_buffer);
}
return v8::Just(result);
}

View file

@ -4723,8 +4723,12 @@ fn value_serializer_not_implemented() {
assert!(scope.stack_trace().is_some());
assert!(scope.message().is_some());
assert_eq!(
scope.message().unwrap().get(scope).to_rust_string_lossy(scope),
"Uncaught Error: Deno serializer: get_shared_array_buffer_id not implemented"
scope
.message()
.unwrap()
.get(scope)
.to_rust_string_lossy(scope),
"Uncaught Error: #<SharedArrayBuffer> could not be cloned."
);
}