Commit 88b8f94c authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

IDL Compiler: Check if value is ArrayBufferView in ToFlexibleArrayBufferView

Before this CL, ToFlexibleArrayBufferView() expected the given |value|
has ArrayBufferView.  But in its use cases, all in generated code, we
don't check the fact, and instead, check the returned value is empty to
throw an exception.

  FlexibleArrayBufferView var;
  // No check v8_var->IsArrayBufferView()
  ToFlexibleArrayBufferView(isolate, v8_var, var);
  if (var.IsEmpty()) { exception_state.ThrowTypeError(...); }

To keep generated code's style, which is consistent with other
ToFooBar(), this CL checks the given V8 value is in a correct type,
and makes return value empty if it's not.


Bug: 1029716
Change-Id: I1e58c998064b90a0a5b09f0e8895c9283a37e45b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1949826Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721901}
parent 391ebba5
......@@ -718,7 +718,10 @@ void ToFlexibleArrayBufferView(v8::Isolate* isolate,
v8::Local<v8::Value> value,
FlexibleArrayBufferView& result,
void* storage) {
DCHECK(value->IsArrayBufferView());
if (!value->IsArrayBufferView()) {
result.Clear();
return;
}
v8::Local<v8::ArrayBufferView> buffer = value.As<v8::ArrayBufferView>();
if (!storage) {
result.SetFull(V8ArrayBufferView::ToImpl(buffer));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment