Commit 693f73fa authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

v8binding: Fix ToFloat to throw

Adds a missing check of exception_state.HadException().

Comment about crbug.com/939598 is not correct because of
    unrestricted float (Web IDL) => ToFloat (Blink)
    float (Web IDL) => ToRestrictedFloat (Blink)
In case of 'unrestricted float', it shouldn't throw an
exception.

Bug: 939598
Change-Id: Ibda1cb445b630f38a8e3ab52c6839a49020d6941
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1574997Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652538}
parent ecdd7645
......@@ -372,9 +372,8 @@ inline float ToFloat(v8::Isolate* isolate,
v8::Local<v8::Value> value,
ExceptionState& exception_state) {
double double_value = ToDouble(isolate, value, exception_state);
// TODO(crbug.com/939598): These cases should throw a TypeError instead
// of returning Infinity; but before fixing that, we must ensure that
// ToFloat is not called in cases where ToDouble should be called instead.
if (exception_state.HadException())
return 0;
using Limits = std::numeric_limits<float>;
if (UNLIKELY(double_value > Limits::max()))
return Limits::infinity();
......
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