Ignore:
Timestamp:
Aug 30, 2013, 11:30:41 AM (12 years ago)
Author:
[email protected]
Message:

Make JSValue bool conversion less dangerous
https://bugs.webkit.org/show_bug.cgi?id=120505

Reviewed by Darin Adler.

Source/JavaScriptCore:

Replaces JSValue::operator bool() with a operator UnspecifiedBoolType* as
we do elsewhere. Then fix the places where terrible type coercion was
happening. All of the changes made had no fundamental behavioural impact
as they were coercion results that were ignored (returning undefined
after an exception).

  • dfg/DFGOperations.cpp:
  • interpreter/CallFrame.h:

(JSC::ExecState::hadException):

  • runtime/JSCJSValue.h:
  • runtime/JSCJSValueInlines.h:

(JSC::JSValue::operator UnspecifiedBoolType*):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval):

  • runtime/PropertyDescriptor.cpp:

(JSC::PropertyDescriptor::equalTo)

Source/WTF:

Make LIKELY and UNLIKELY macros coerce to bool before
passing to expect.

  • wtf/Compiler.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.h

    r153296 r154902  
    174174    explicit JSValue(unsigned long long);
    175175
    176     operator bool() const;
     176    typedef void* (JSValue::*UnspecifiedBoolType);
     177    operator UnspecifiedBoolType*() const;
    177178    bool operator==(const JSValue& other) const;
    178179    bool operator!=(const JSValue& other) const;
Note: See TracChangeset for help on using the changeset viewer.