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/dfg/DFGOperations.cpp

    r154824 r154902  
    678678    if (!base->isObject()) {
    679679        vm->throwException(exec, createInvalidParameterError(exec, "in", base));
    680         return jsUndefined();
     680        return JSValue::encode(jsUndefined());
    681681    }
    682682   
     
    705705    if (!base->isObject()) {
    706706        vm->throwException(exec, createInvalidParameterError(exec, "in", base));
    707         return jsUndefined();
     707        return JSValue::encode(jsUndefined());
    708708    }
    709709
Note: See TracChangeset for help on using the changeset viewer.