Ignore:
Timestamp:
Oct 31, 2006, 6:14:01 PM (19 years ago)
Author:
ggaren
Message:

JavaScriptCore:

Reviewed by Beth.


Fixed http://bugs.webkit.org/show_bug.cgi?id=11477
REGRESSION: GMail crashes in KJS::FunctionImp::callerGetter

  • kjs/function.cpp: (KJS::FunctionImp::argumentsGetter): Removed unnecessary braces. (KJS::FunctionImp::callerGetter): More logical NULL checking.

LayoutTests:

Added test for accessing the 'caller' property from inside an event
listener.

  • fast/events/caller-access-from-event-listener-expected.txt: Added.
  • fast/events/caller-access-from-event-listener.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/function.cpp

    r17483 r17507  
    220220  Context* context = exec->m_context;
    221221  while (context) {
    222     if (context->function() == thisObj) {
     222    if (context->function() == thisObj)
    223223      return static_cast<ActivationImp*>(context->activationObject())->get(exec, propertyName);
    224     }
    225224    context = context->callingContext();
    226225  }
     
    230229JSValue* FunctionImp::callerGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot)
    231230{
    232     FunctionImp* thisObj = static_cast<FunctionImp* >(slot.slotBase());
     231    FunctionImp* thisObj = static_cast<FunctionImp*>(slot.slotBase());
    233232    Context* context = exec->m_context;
    234233    while (context) {
    235         if (context->function() == thisObj)
    236             return (context->callingContext()->function()) ? context->callingContext()->function() : jsNull();
    237        
     234        if (context->function() == thisObj)
     235            break;
    238236        context = context->callingContext();
    239237    }
    240     return jsNull();
     238
     239    if (!context)
     240        return jsNull();
     241   
     242    Context* callingContext = context->callingContext();
     243    if (!callingContext)
     244        return jsNull();
     245   
     246    FunctionImp* callingFunction = callingContext->function();
     247    if (!callingFunction)
     248        return jsNull();
     249
     250    return callingFunction;
    241251}
    242252
Note: See TracChangeset for help on using the changeset viewer.