⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 278660 in webkit


Ignore:
Timestamp:
Jun 9, 2021, 8:21:39 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Fix inadvertent tag corruption in functionAddressOf
https://bugs.webkit.org/show_bug.cgi?id=226503

Patch by Mikhail R. Gadelha <Mikhail R. Gadelha> on 2021-06-09
Reviewed by Darin Adler.

Original patch by Angelos Oikonomopoulos.

The cast was sign-extending the JSValue address in 32 bits, so that addresses
that had the most significant set gave us a sign-extended result in
asNumber which was then converted to an invalid NaN by the bitcast.

Instead, cast the address to uintptr_t, and the result will be promoted
uint64_t without sign-extending the address.

  • jsc.cpp:

(JSC_DEFINE_HOST_FUNCTION):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r278656 r278660  
     12021-06-09  Mikhail R. Gadelha  <mikhail@igalia.com>
     2
     3        Fix inadvertent tag corruption in functionAddressOf
     4        https://bugs.webkit.org/show_bug.cgi?id=226503
     5
     6        Reviewed by Darin Adler.
     7
     8        Original patch by Angelos Oikonomopoulos.
     9
     10        The cast was sign-extending the JSValue address in 32 bits, so that addresses
     11        that had the most significant set gave us a sign-extended result in
     12        asNumber which was then converted to an invalid NaN by the bitcast.
     13
     14        Instead, cast the address to uintptr_t, and the result will be promoted
     15        uint64_t without sign-extending the address.
     16
     17        * jsc.cpp:
     18        (JSC_DEFINE_HOST_FUNCTION):
     19
    1202021-06-08  Yusuke Suzuki  <ysuzuki@apple.com>
    221
  • trunk/Source/JavaScriptCore/jsc.cpp

    r278516 r278660  
    14811481        return JSValue::encode(jsUndefined());
    14821482    // Need to cast to uint64_t so bitwise_cast will play along.
    1483     uint64_t asNumber = reinterpret_cast<uint64_t>(value.asCell());
     1483    uint64_t asNumber = reinterpret_cast<uintptr_t>(value.asCell());
    14841484    EncodedJSValue returnValue = JSValue::encode(jsNumber(bitwise_cast<double>(asNumber)));
    14851485    return returnValue;
Note: See TracChangeset for help on using the changeset viewer.