Changeset 60754


Ignore:
Timestamp:
06/05/10 13:19:21 (5 years ago)
Author:
dumi@chromium.org
Message:

Do not pass empty handles to v8.
https://bugs.webkit.org/show_bug.cgi?id=39896

Reviewed by Adam Barth.

Passing an empty handle to v8 results in a crash with a stack
trace that doesn't give us much information about the cause of the
crash. Instead, if we check the handles we pass to v8 and crash
when they are empty, we do not make things worse, and should get a
more informative stack trace.

  • bindings/scripts/CodeGeneratorV8.pm:
  • bindings/scripts/test/V8/V8TestCallback.cpp:

(WebCore::V8TestCallback::callbackWithClass1Param):
(WebCore::V8TestCallback::callbackWithClass2Param):

  • bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp:

(WebCore::V8SQLStatementErrorCallback::handleEvent):

Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r60753 r60754  
     12010-05-28  Dumitru Daniliuc  <dumi@chromium.org> 
     2 
     3        Reviewed by Adam Barth. 
     4 
     5        Do not pass empty handles to v8. 
     6        https://bugs.webkit.org/show_bug.cgi?id=39896 
     7 
     8        Passing an empty handle to v8 results in a crash with a stack 
     9        trace that doesn't give us much information about the cause of the 
     10        crash. Instead, if we check the handles we pass to v8 and crash 
     11        when they are empty, we do not make things worse, and should get a 
     12        more informative stack trace. 
     13 
     14        * bindings/scripts/CodeGeneratorV8.pm: 
     15        * bindings/scripts/test/V8/V8TestCallback.cpp: 
     16        (WebCore::V8TestCallback::callbackWithClass1Param): 
     17        (WebCore::V8TestCallback::callbackWithClass2Param): 
     18        * bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp: 
     19        (WebCore::V8SQLStatementErrorCallback::handleEvent): 
     20 
    1212010-05-30  Antonio Gomes  <tonikitoo@webkit.org> 
    222 
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r60670 r60754  
    22372237    $implIncludes{"V8CustomVoidCallback.h"} = 1; 
    22382238 
     2239    push(@implContent, "#include <wtf/Assertions.h>\n\n"); 
    22392240    push(@implContent, "namespace WebCore {\n\n"); 
    22402241    push(@implContent, <<END); 
     
    22782279            push(@implContent, "        return true;\n\n"); 
    22792280            push(@implContent, "    v8::Context::Scope scope(v8Context);\n\n"); 
    2280             push(@implContent, "    v8::Handle<v8::Value> argv[] = {\n"); 
    22812281 
    22822282            my @argvs = (); 
    22832283            foreach my $param (@params) { 
    22842284                my $paramName = $param->name; 
    2285                 push(@argvs, "        toV8(${paramName})"); 
     2285                push(@implContent, "    v8::Handle<v8::Value> ${paramName}Handle = toV8(${paramName});\n"); 
     2286                push(@implContent, "    if (${paramName}Handle.IsEmpty()) {\n"); 
     2287                push(@implContent, "        CRASH();\n"); 
     2288                push(@implContent, "        return true;\n"); 
     2289                push(@implContent, "    }\n"); 
     2290                push(@argvs, "        ${paramName}Handle"); 
    22862291            } 
     2292 
     2293            push(@implContent, "\n    v8::Handle<v8::Value> argv[] = {\n"); 
    22872294            push(@implContent, join(",\n", @argvs)); 
    2288  
    22892295            push(@implContent, "\n    };\n\n"); 
    22902296            push(@implContent, "    bool callbackReturnValue = false;\n"); 
  • trunk/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp

    r60330 r60754  
    3030#include "V8DOMString.h" 
    3131 
     32#include <wtf/Assertions.h> 
     33 
    3234namespace WebCore { 
    3335 
     
    5557    v8::Context::Scope scope(v8Context); 
    5658 
     59    v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param); 
     60    if (class1ParamHandle.IsEmpty()) { 
     61        CRASH(); 
     62        return true; 
     63    } 
     64 
    5765    v8::Handle<v8::Value> argv[] = { 
    58         toV8(class1Param) 
     66        class1ParamHandle 
    5967    }; 
    6068 
     
    7381    v8::Context::Scope scope(v8Context); 
    7482 
     83    v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param); 
     84    if (class2ParamHandle.IsEmpty()) { 
     85        CRASH(); 
     86        return true; 
     87    } 
     88    v8::Handle<v8::Value> strArgHandle = toV8(strArg); 
     89    if (strArgHandle.IsEmpty()) { 
     90        CRASH(); 
     91        return true; 
     92    } 
     93 
    7594    v8::Handle<v8::Value> argv[] = { 
    76         toV8(class2Param), 
    77         toV8(strArg) 
     95        class2ParamHandle, 
     96        strArgHandle 
    7897    }; 
    7998 
  • trunk/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp

    r60330 r60754  
    4040#include "V8SQLError.h" 
    4141#include "V8SQLTransaction.h" 
     42#include <wtf/Assertions.h> 
    4243 
    4344namespace WebCore { 
     
    5354    v8::Context::Scope scope(v8Context); 
    5455 
     56    v8::Handle<v8::Value> transactionHandle = toV8(transaction); 
     57    v8::Handle<v8::Value> errorHandle = toV8(error); 
     58    if (transactionHandle.IsEmpty() || errorHandle.isEmpty()) { 
     59        CRASH(); 
     60        return true; 
     61    } 
     62 
    5563    v8::Handle<v8::Value> argv[] = { 
    56         toV8(transaction), 
    57         toV8(error) 
     64        transactionHandle, 
     65        errorHandle 
    5866    }; 
    5967 
Note: See TracChangeset for help on using the changeset viewer.