[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:08:34 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 8edc20a06cbe23d3ea656ca1cbfae1b44c74b62b
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Nov 2 05:37:29 2003 +0000

            Reviewed by Maciej.
    
            - fixed 3470882 -- storage leaks in WebDownload code
            - fixed 3470884 -- download is always nil in downloadWindowForAuthenticationSheet: call from WebDownload
    
            * Misc.subproj/WebDownload.m:
            (-[WebDownloadInternal initWithDownload:]): Removed this method, which was never called.
            (-[WebDownloadInternal dealloc]): Added missing call to [super dealloc] to fix one cause
            of a leak of the WebDownloadInternal object itself. Removed the release of webDownload,
            which was always nil, and if it wasn't would end up causing a leak due to a reference cycle.
            (-[WebDownloadInternal download:didReceiveAuthenticationChallenge:]): Remove the use of
            webDownload, which was always nil, and instead use the download parameter passed to us,
            casting it to WebDownload, since it's guaranteed to be one.
            (-[WebDownload _setRealDelegate:]): Added. Shared by the methods below to set up the real
            delegate before calling init. The old code called init twice, causing an second call to the
            superclass's init method, which caused it to create an extra copy of its internal structure,
            as well as causing us to create two WebDownloadInternal objects.
            (-[WebDownload init]): Don't allocate a second WebDownloadInternal if _setRealDelegate already
            allocated it for us. Before we would allocate and leak an extra one each time.
            (-[WebDownload dealloc]): Added. Releases the WebDownloadInternal. This is the second cause
            of the leak of the WebDownloadInternal object.
            (-[WebDownload initWithRequest:delegate:]): Call [self _setRealDelegate:] instead of calling
            [self init] and then [_webInternal setRealDelegate:], avoiding the leaks caused by doing it
            the other way.
            (-[WebDownload _initWithLoadingConnection:request:response:delegate:proxy:]): Ditto.
            (-[WebDownload _initWithLoadingResource:request:response:delegate:proxy:]): Ditto.
            (-[WebDownload _initWithRequest:delegate:directory:]): Ditto.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5355 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 05b0cb5..cf25561 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,33 @@
+2003-11-01  Darin Adler  <darin at apple.com>
+
+        Reviewed by Maciej.
+
+        - fixed 3470882 -- storage leaks in WebDownload code
+        - fixed 3470884 -- download is always nil in downloadWindowForAuthenticationSheet: call from WebDownload
+
+        * Misc.subproj/WebDownload.m:
+        (-[WebDownloadInternal initWithDownload:]): Removed this method, which was never called.
+        (-[WebDownloadInternal dealloc]): Added missing call to [super dealloc] to fix one cause
+        of a leak of the WebDownloadInternal object itself. Removed the release of webDownload,
+        which was always nil, and if it wasn't would end up causing a leak due to a reference cycle.
+        (-[WebDownloadInternal download:didReceiveAuthenticationChallenge:]): Remove the use of
+        webDownload, which was always nil, and instead use the download parameter passed to us,
+        casting it to WebDownload, since it's guaranteed to be one.
+        (-[WebDownload _setRealDelegate:]): Added. Shared by the methods below to set up the real
+        delegate before calling init. The old code called init twice, causing an second call to the
+        superclass's init method, which caused it to create an extra copy of its internal structure,
+        as well as causing us to create two WebDownloadInternal objects.
+        (-[WebDownload init]): Don't allocate a second WebDownloadInternal if _setRealDelegate already
+        allocated it for us. Before we would allocate and leak an extra one each time.
+        (-[WebDownload dealloc]): Added. Releases the WebDownloadInternal. This is the second cause
+        of the leak of the WebDownloadInternal object.
+        (-[WebDownload initWithRequest:delegate:]): Call [self _setRealDelegate:] instead of calling
+        [self init] and then [_webInternal setRealDelegate:], avoiding the leaks caused by doing it
+        the other way.
+        (-[WebDownload _initWithLoadingConnection:request:response:delegate:proxy:]): Ditto.
+        (-[WebDownload _initWithLoadingResource:request:response:delegate:proxy:]): Ditto.
+        (-[WebDownload _initWithRequest:delegate:directory:]): Ditto.
+
 2003-10-31  David Hyatt  <hyatt at apple.com>
 
 	Fix for 3466542, add a real minimum font size setting.
diff --git a/WebKit/Misc.subproj/WebDownload.m b/WebKit/Misc.subproj/WebDownload.m
index 7e0dbc8..597394e 100644
--- a/WebKit/Misc.subproj/WebDownload.m
+++ b/WebKit/Misc.subproj/WebDownload.m
@@ -4,12 +4,14 @@
 
 #import <WebKit/WebDownload.h>
 
-#import <Foundation/NSURLDownload.h>
 #import <Foundation/NSURLAuthenticationChallenge.h>
+#import <Foundation/NSURLDownload.h>
 #import <Foundation/NSURLDownloadPrivate.h>
+#import <WebKit/WebAssertions.h>
 #import <WebKit/WebPanelAuthenticationHandler.h>
 
 // FIXME: Remove these declarations because _initWithLoadingConnection is declared in NSURLDownloadPrivate.h
+// and _initWithLoadingResource is obsolete, once we compile only with the new Foundation.
 @interface NSURLDownload (WebDownloadCapability)
 - (id)_initWithLoadingConnection:(NSURLConnection *)connection
                          request:(NSURLRequest *)request
@@ -27,7 +29,6 @@
 {
 @public
     id realDelegate;
-    WebDownload *webDownload;
 }
 
 - (void)setRealDelegate:(id)rd;
@@ -36,19 +37,10 @@
 
 @implementation WebDownloadInternal
 
-- (id)initWithDownload:(WebDownload *)dl
-{
-    self = [super init];
-    if (self != nil) {
-	webDownload = [dl retain];
-    }
-    return self;
-}
-
 - (void)dealloc
 {
-    [webDownload release];
     [realDelegate release];
+    [super dealloc];
 }
 
 - (void)setRealDelegate:(id)rd
@@ -94,7 +86,7 @@
     } else {
 	NSWindow *window = nil;
 	if ([realDelegate respondsToSelector:@selector(downloadWindowForAuthenticationSheet:)]) {
-	    window = [realDelegate downloadWindowForAuthenticationSheet:webDownload];
+	    window = [realDelegate downloadWindowForAuthenticationSheet:(WebDownload *)download];
 	}
 
 	[[WebPanelAuthenticationHandler sharedHandler] startAuthentication:challenge window:window];
@@ -157,37 +149,50 @@
 
 @end
 
-
-
 @implementation WebDownload
 
+- (void)_setRealDelegate:(id)delegate
+{
+    if (_webInternal == nil) {
+        _webInternal = [[WebDownloadInternal alloc] init];
+        [_webInternal setRealDelegate:delegate];
+    } else {
+        ASSERT(_webInternal == delegate);
+    }
+}
+
 - (id)init
 {
     self = [super init];
     if (self != nil) {
-	_webInternal = [[WebDownloadInternal alloc] init];
+        // _webInternal can be set up before init by _setRealDelegate
+	if (_webInternal == nil) {
+            _webInternal = [[WebDownloadInternal alloc] init];
+        }
     }
     return self;
 }
 
+- (void)dealloc
+{
+    [_webInternal release];
+    [super dealloc];
+}
+
 - (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate
 {
-    self = [self init];
-    [_webInternal setRealDelegate:delegate];
-    [super initWithRequest:request delegate:_webInternal];
-    return self;
+    [self _setRealDelegate:delegate];
+    return [super initWithRequest:request delegate:_webInternal];
 }
 
 - (id)_initWithLoadingConnection:(NSURLConnection *)connection
                          request:(NSURLRequest *)request
                         response:(NSURLResponse *)response
                         delegate:(id)delegate
-                           proxy:(NSURLConnectionDelegateProxy *)proxy;
+                           proxy:(NSURLConnectionDelegateProxy *)proxy
 {
-    self = [self init];
-    [_webInternal setRealDelegate:delegate];
-    [super _initWithLoadingConnection:connection request:request response:response delegate:_webInternal proxy:proxy];
-    return self;
+    [self _setRealDelegate:delegate];
+    return [super _initWithLoadingConnection:connection request:request response:response delegate:_webInternal proxy:proxy];
 }
 
 // FIXME: Remove this override because it no longer exists in newer Foundations.
@@ -195,22 +200,18 @@
                        request:(NSURLRequest *)request
                       response:(NSURLResponse *)response
                       delegate:(id)delegate
-                         proxy:(NSURLConnectionDelegateProxy *)proxy;
+                         proxy:(NSURLConnectionDelegateProxy *)proxy
 {
-    self = [self init];
-    [_webInternal setRealDelegate:delegate];
-    [super _initWithLoadingResource:connection request:request response:response delegate:_webInternal proxy:proxy];
-    return self;
+    [self _setRealDelegate:delegate];
+    return [super _initWithLoadingResource:connection request:request response:response delegate:_webInternal proxy:proxy];
 }
 
 - (id)_initWithRequest:(NSURLRequest *)request
               delegate:(id)delegate
              directory:(NSString *)directory
 {
-    self = [self init];
-    [_webInternal setRealDelegate:delegate];
-    [super _initWithRequest:request delegate:_webInternal directory:directory];
-    return self;
+    [self _setRealDelegate:delegate];
+    return [super _initWithRequest:request delegate:_webInternal directory:directory];
 }
 
 @end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list