Reviewed by Stephanie.
authorweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2007 03:10:04 +0000 (03:10 +0000)
committerweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2007 03:10:04 +0000 (03:10 +0000)
        Fix leaks in mac DumpRenderTree.

        * DumpRenderTree/FrameLoadDelegate.mm:
        (-[FrameLoadDelegate init]): Initalize in the correct order.
        (-[FrameLoadDelegate processWork:]): Delete WorkQueueItem's after dequeueing them.
        * DumpRenderTree/LayoutTestController.cpp:
        (decodeHostNameCallback): Put return value in a temporary JSRetainPtr to ensure it gets released.
        (encodeHostNameCallback): ditto.
        * DumpRenderTree/LayoutTestController.h:
        * DumpRenderTree/LayoutTestControllerMac.mm:
        (LayoutTestController::copyDecodedHostName): Rename function to signal that it follows the Create rule.
        (LayoutTestController::copyEncodedHostName): ditto
        (LayoutTestController::queueLoad): Use a JSRetainPtr to ensure the url gets released.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25529 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/FrameLoadDelegate.mm
WebKitTools/DumpRenderTree/LayoutTestController.cpp
WebKitTools/DumpRenderTree/LayoutTestController.h
WebKitTools/DumpRenderTree/LayoutTestControllerMac.mm

index 512c9c5f2fe63279656b01ba6229e2787d346041..9e66eba591d7023e30739f8bf228530ee501c794 100644 (file)
@@ -1,3 +1,21 @@
+2007-09-12  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Stephanie.
+
+        Fix leaks in mac DumpRenderTree.
+
+        * DumpRenderTree/FrameLoadDelegate.mm:
+        (-[FrameLoadDelegate init]): Initalize in the correct order.
+        (-[FrameLoadDelegate processWork:]): Delete WorkQueueItem's after dequeueing them.
+        * DumpRenderTree/LayoutTestController.cpp:
+        (decodeHostNameCallback): Put return value in a temporary JSRetainPtr to ensure it gets released.
+        (encodeHostNameCallback): ditto.
+        * DumpRenderTree/LayoutTestController.h:
+        * DumpRenderTree/LayoutTestControllerMac.mm:
+        (LayoutTestController::copyDecodedHostName): Rename function to signal that it follows the Create rule.
+        (LayoutTestController::copyEncodedHostName): ditto
+        (LayoutTestController::queueLoad): Use a JSRetainPtr to ensure the url gets released.
+
 2007-09-12  Kevin McCullough  <kmccullough@apple.com>
 
         Reviewed by Darin.
index 1d2f1af296e24be2bf4da25e3c4bff0f44a3a54f..edeee1e2cba1f749d88ddf53feb81c5f4014c3be 100644 (file)
@@ -94,8 +94,9 @@
 
 - (id)init
 {
-    layoutTestContoller = new LayoutTestController();
-    return [super init];
+    if ((self = [super init]))
+        layoutTestContoller = new LayoutTestController;
+    return self;
 }
 
 - (void)dealloc
         WorkQueueItem* item = WorkQueue::shared()->dequeue();
         ASSERT(item);
         item->invoke();
+        delete item;
     }
     
     // if we didn't start a new load, then we finished all the commands, so we're ready to dump state
index 3d9131aab03610b52754c2e62a0eb481635c0b4c..4ff4aa0eef2a6f63539078ab98005d0f6bc711b5 100644 (file)
@@ -163,8 +163,6 @@ static JSValueRef addFileToPasteboardOnDragCallback(JSContextRef context, JSObje
     return JSValueMakeUndefined(context);
 }
 
-#pragma mark Require implementation
-
 static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     // Has mac implementation
@@ -199,7 +197,8 @@ static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef funct
     ASSERT(!*exception);
 
     LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
-    return JSValueMakeString(context, controller->decodeHostName(name.get()));
+    JSRetainPtr<JSStringRef> decodedHostName(Adopt, controller->copyDecodedHostName(name.get()));
+    return JSValueMakeString(context, decodedHostName.get());
 }
 
 static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
@@ -221,7 +220,8 @@ static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef funct
     ASSERT(!*exception);
 
     LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
-    return JSValueMakeString(context, controller->encodeHostName(name.get()));
+    JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get()));
+    return JSValueMakeString(context, encodedHostName.get());
 }
 
 static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
index 53c8cd35e14047cef044b23bdfaa9bcd8fa375c1..d2651afd99e049ca5cd96532e47ca77103f28fbc 100644 (file)
@@ -58,8 +58,8 @@ public:
     void addFileToPasteboardOnDrag();
     void addDisallowedURL(JSStringRef url);
     void clearBackForwardList();
-    JSStringRef decodeHostName(JSStringRef name);
-    JSStringRef encodeHostName(JSStringRef name);
+    JSStringRef copyDecodedHostName(JSStringRef name);
+    JSStringRef copyEncodedHostName(JSStringRef name);
     void display();
     void keepWebHistory();
     void notifyDone();
index 9e53b3f1623bcdb4a1af39a38fc10b1a63385756..c4cd27227d7a85b3440b15fd44a869f7c3a2dad3 100644 (file)
@@ -161,14 +161,14 @@ void LayoutTestController::clearBackForwardList()
     [item release];
 }
 
-JSStringRef LayoutTestController::decodeHostName(JSStringRef name)
+JSStringRef LayoutTestController::copyDecodedHostName(JSStringRef name)
 {
     RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, name));
     NSString *nameNS = (NSString *)nameCF.get();
     return JSStringCreateWithCFString((CFStringRef)[nameNS _web_decodeHostName]);
 }
 
-JSStringRef LayoutTestController::encodeHostName(JSStringRef name)
+JSStringRef LayoutTestController::copyEncodedHostName(JSStringRef name)
 {
     RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, name));
     NSString *nameNS = (NSString *)nameCF.get();
@@ -214,7 +214,8 @@ void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target)
     NSURL *nsurl = [NSURL URLWithString:urlNS relativeToURL:[[[mainFrame dataSource] response] URL]];
     NSString* nsurlString = [nsurl absoluteString];
 
-    WorkQueue::shared()->queue(new LoadItem(JSStringCreateWithUTF8CString([nsurlString UTF8String]), target));
+    JSRetainPtr<JSStringRef> absoluteURL(Adopt, JSStringCreateWithUTF8CString([nsurlString UTF8String]));
+    WorkQueue::shared()->queue(new LoadItem(absoluteURL.get(), target));
 }
 
 void LayoutTestController::queueReload()