diff options
author | Jack Karamanian <karamanian.jack@gmail.com> | 2020-04-06 22:48:47 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-07 08:41:25 +0200 |
commit | 57bd194e5a11ae6bc8477eb976fb7d2c1e10ac35 (patch) | |
tree | c441aaa117f620dfeb9da7529497702341e91aef /Libraries/LibJS/Runtime/Value.cpp | |
parent | 4a9485f830c1134177cbd066fdeb24458d1ec4d0 (diff) | |
download | serenity-57bd194e5a11ae6bc8477eb976fb7d2c1e10ac35.zip |
LibJS: Return false for NaN numbers in Value::to_boolean()
Diffstat (limited to 'Libraries/LibJS/Runtime/Value.cpp')
-rw-r--r-- | Libraries/LibJS/Runtime/Value.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Libraries/LibJS/Runtime/Value.cpp b/Libraries/LibJS/Runtime/Value.cpp index 77d2fcc4f9..6e5d11c3ba 100644 --- a/Libraries/LibJS/Runtime/Value.cpp +++ b/Libraries/LibJS/Runtime/Value.cpp @@ -83,6 +83,9 @@ bool Value::to_boolean() const case Type::Boolean: return m_value.as_bool; case Type::Number: + if (is_nan()) { + return false; + } return !(m_value.as_double == 0 || m_value.as_double == -0); case Type::Null: case Type::Undefined: |