Commit a7735565 authored by ggaren's avatar ggaren
Browse files

Reviewed by John.

        
        - Fixed a few crashes resulting from NULL parameters to JSClassCreate.

        * API/JSClassRef.cpp:
        (JSClassCreate):
        (JSClassRelease):
        * API/testapi.c: Added test for NULL parameters.
        (main):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15213 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 80b420ae
......@@ -37,7 +37,7 @@ JSClassRef JSClassCreate(JSContextRef, JSStaticValue* staticValues, JSStaticFunc
JSClassRef jsClass = new __JSClass;
if (staticValues) {
jsClass->staticValues = new __JSClass::StaticValuesTable();
while (staticValues->name != 0) {
while (staticValues->name) {
jsClass->staticValues->add(Identifier(staticValues->name).ustring().rep(),
new StaticValueEntry(staticValues->getProperty, staticValues->setProperty, staticValues->attributes));
++staticValues;
......@@ -46,14 +46,18 @@ JSClassRef JSClassCreate(JSContextRef, JSStaticValue* staticValues, JSStaticFunc
if (staticFunctions) {
jsClass->staticFunctions = new __JSClass::StaticFunctionsTable();
while (staticFunctions->name != 0) {
while (staticFunctions->name) {
jsClass->staticFunctions->add(Identifier(staticFunctions->name).ustring().rep(),
new StaticFunctionEntry(staticFunctions->callAsFunction, staticFunctions->attributes));
++staticFunctions;
}
}
jsClass->callbacks = *callbacks;
if (callbacks)
jsClass->callbacks = *callbacks;
else
jsClass->callbacks = kJSObjectCallbacksNone;
jsClass->parent = parentClass;
return JSClassRetain(jsClass);
......@@ -68,11 +72,15 @@ JSClassRef JSClassRetain(JSClassRef jsClass)
void JSClassRelease(JSClassRef jsClass)
{
if (--jsClass->refCount == 0) {
deleteAllValues(*jsClass->staticValues);
delete jsClass->staticValues;
if (jsClass->staticValues) {
deleteAllValues(*jsClass->staticValues);
delete jsClass->staticValues;
}
deleteAllValues(*jsClass->staticFunctions);
delete jsClass->staticFunctions;
if (jsClass->staticFunctions) {
deleteAllValues(*jsClass->staticFunctions);
delete jsClass->staticFunctions;
}
delete jsClass;
}
......
......@@ -564,6 +564,9 @@ int main(int argc, char* argv[])
JSObjectSetProperty(context, globalObject, myConstructorBuf, JSConstructorMake(context, myConstructor_callAsConstructor), kJSPropertyAttributeNone);
JSStringBufferRelease(myConstructorBuf);
JSClassRef nullCallbacksClass = JSClassCreate(context, NULL, NULL, NULL, NULL);
JSClassRelease(nullCallbacksClass);
char* script = createStringWithContentsOfFile("testapi.js");
JSStringBufferRef scriptBuf = JSStringBufferCreateUTF8(script);
result = JSEvaluate(context, scriptBuf, NULL, NULL, 1, &exception);
......
2006-07-07 Geoffrey Garen <ggaren@apple.com>
Reviewed by John.
- Fixed a few crashes resulting from NULL parameters to JSClassCreate.
* API/JSClassRef.cpp:
(JSClassCreate):
(JSClassRelease):
* API/testapi.c: Added test for NULL parameters.
(main):
2006-07-07 Geoffrey Garen <ggaren@apple.com>
 
Reviewed by John, mocked by Darin.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment