Changeset 51312 in webkit


Ignore:
Timestamp:
Nov 23, 2009 11:12:08 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2009-11-23 Adam Barth <abarth@webkit.org>

Reviewed by Dimitri Glazkov.

[V8] Don't crash when OOM in creating isolated world
https://bugs.webkit.org/show_bug.cgi?id=31805

We need to add some more null checks to avoid crashing. No new tests
because we don't have a good way to test out-of-memory bugs.

  • bindings/v8/V8Proxy.cpp: (WebCore::V8Proxy::evaluateInIsolatedWorld): (WebCore::V8Proxy::evaluateInNewContext): (WebCore::V8Proxy::setInjectedScriptContextDebugId):
  • bindings/v8/V8Proxy.h:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51310 r51312  
     12009-11-23  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        [V8] Don't crash when OOM in creating isolated world
     6        https://bugs.webkit.org/show_bug.cgi?id=31805
     7
     8        We need to add some more null checks to avoid crashing.  No new tests
     9        because we don't have a good way to test out-of-memory bugs.
     10
     11        * bindings/v8/V8Proxy.cpp:
     12        (WebCore::V8Proxy::evaluateInIsolatedWorld):
     13        (WebCore::V8Proxy::evaluateInNewContext):
     14        (WebCore::V8Proxy::setInjectedScriptContextDebugId):
     15        * bindings/v8/V8Proxy.h:
     16
    1172009-11-23  Dirk Schulze  <krit@webkit.org>
    218
  • trunk/WebCore/bindings/v8/V8Proxy.cpp

    r50993 r51312  
    312312
    313313            // Setup context id for JS debugger.
    314             setInjectedScriptContextDebugId(world->context());
     314            if (!setInjectedScriptContextDebugId(world->context())) {
     315                m_isolatedWorlds.take(worldID);
     316                delete world;
     317                return;
     318            }
    315319        }
    316320    } else {
     
    351355
    352356    // Setup context id for JS debugger.
    353     setInjectedScriptContextDebugId(context);
     357    if (!setInjectedScriptContextDebugId(context)) {
     358        context.Dispose();
     359        return;
     360    }
    354361
    355362    v8::Handle<v8::Object> global = context->Global();
     
    377384}
    378385
    379 void V8Proxy::setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContext)
     386bool V8Proxy::setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContext)
    380387{
    381388    // Setup context id for JS debugger.
    382389    v8::Context::Scope contextScope(targetContext);
    383390    v8::Handle<v8::Object> contextData = v8::Object::New();
    384 
     391    if (contextData.IsEmpty())
     392        return false;
     393
     394    if (m_context.IsEmpty())
     395        return false;
    385396    v8::Handle<v8::Value> windowContextData = m_context->GetData();
    386397    if (windowContextData->IsObject()) {
    387398        v8::Handle<v8::String> propertyName = v8::String::New(kContextDebugDataValue);
     399        if (propertyName.IsEmpty())
     400            return false;
    388401        contextData->Set(propertyName, v8::Object::Cast(*windowContextData)->Get(propertyName));
    389402    }
    390     contextData->Set(v8::String::New(kContextDebugDataType), v8::String::New("injected"));
     403    v8::Handle<v8::String> propertyName = v8::String::New(kContextDebugDataType);
     404    if (propertyName.IsEmpty())
     405        return false;
     406    contextData->Set(propertyName, v8::String::New("injected"));
    391407    targetContext->SetData(contextData);
     408    return true;
    392409}
    393410
  • trunk/WebCore/bindings/v8/V8Proxy.h

    r50958 r51312  
    388388        void resetIsolatedWorlds();
    389389
    390         void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContext);
     390        // Returns false when we're out of memory in V8.
     391        bool setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContext);
    391392
    392393        static bool canAccessPrivate(DOMWindow*);
Note: See TracChangeset for help on using the changeset viewer.