ValueDeserializer: Make sure that an exception is the legacy path.
The entry points to the deserializer are responsible for ensuring that an exception is pending by the time they return. Some failures throw exceptions themselves, while others (like errors in the format) are exceptions caused by the deserializer, not coming from the runtime. Like the non-legacy path, a default deserialization exception should be thrown in such cases. BUG=chromium:693411 Review-Url: https://codereview.chromium.org/2712713002 Cr-Commit-Position: refs/heads/master@{#43390}
This commit is contained in:
parent
2a2fc69221
commit
68960eeb76
@ -1849,6 +1849,20 @@ static Maybe<bool> SetPropertiesFromKeyValuePairs(Isolate* isolate,
|
||||
return Just(true);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// Throws a generic "deserialization failed" exception by default, unless a more
|
||||
// specific exception has already been thrown.
|
||||
void ThrowDeserializationExceptionIfNonePending(Isolate* isolate) {
|
||||
if (!isolate->has_pending_exception()) {
|
||||
isolate->Throw(*isolate->factory()->NewError(
|
||||
MessageTemplate::kDataCloneDeserializationError));
|
||||
}
|
||||
DCHECK(isolate->has_pending_exception());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MaybeHandle<Object>
|
||||
ValueDeserializer::ReadObjectUsingEntireBufferForLegacyFormat() {
|
||||
DCHECK_EQ(version_, 0u);
|
||||
@ -1881,7 +1895,7 @@ ValueDeserializer::ReadObjectUsingEntireBufferForLegacyFormat() {
|
||||
!SetPropertiesFromKeyValuePairs(
|
||||
isolate_, js_object, &stack[begin_properties], num_properties)
|
||||
.FromMaybe(false)) {
|
||||
DCHECK(isolate_->has_pending_exception());
|
||||
ThrowDeserializationExceptionIfNonePending(isolate_);
|
||||
return MaybeHandle<Object>();
|
||||
}
|
||||
|
||||
@ -1912,7 +1926,7 @@ ValueDeserializer::ReadObjectUsingEntireBufferForLegacyFormat() {
|
||||
!SetPropertiesFromKeyValuePairs(
|
||||
isolate_, js_array, &stack[begin_properties], num_properties)
|
||||
.FromMaybe(false)) {
|
||||
DCHECK(isolate_->has_pending_exception());
|
||||
ThrowDeserializationExceptionIfNonePending(isolate_);
|
||||
return MaybeHandle<Object>();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user