[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 06:56:02 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 5d0c94d5f1b27c3dd73ed47af0e1917982049122
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 30 19:17:03 2002 +0000

    	- fixed memory leaks in plugin package creation code
    
            * Plugins.subproj/WebNetscapePluginPackage.m:
            (-[WebNetscapePluginPackage initWithPath:]): Rearrange this code, and make sure
    	that it does a [self release] if it's going to return nil instead of self.
            (-[WebNetscapePluginPackage unload]): Set bundle to 0 when we release it.
            (-[WebNetscapePluginPackage dealloc]): Release the bundle if it's not 0.
    
            * Plugins.subproj/WebPluginPackage.m:
            (-[WebPluginPackage initWithPath:]): Rearrange this code, and make sure
    	that it does a [self release] if it's going to return nil instead of self.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2509 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 38f70b6..ed655ea 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,5 +1,19 @@
 2002-10-30  Darin Adler  <darin at apple.com>
 
+	- fixed memory leaks in plugin package creation code
+
+        * Plugins.subproj/WebNetscapePluginPackage.m:
+        (-[WebNetscapePluginPackage initWithPath:]): Rearrange this code, and make sure
+	that it does a [self release] if it's going to return nil instead of self.
+        (-[WebNetscapePluginPackage unload]): Set bundle to 0 when we release it.
+        (-[WebNetscapePluginPackage dealloc]): Release the bundle if it's not 0.
+
+        * Plugins.subproj/WebPluginPackage.m:
+        (-[WebPluginPackage initWithPath:]): Rearrange this code, and make sure
+	that it does a [self release] if it's going to return nil instead of self.
+
+2002-10-30  Darin Adler  <darin at apple.com>
+
 	- fixed 3086564 -- REGRESSION: meta-refresh to the same page doesn't refresh
 
 	The key is to respect the new reload: parameter from the bridge.
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 38f70b6..ed655ea 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,5 +1,19 @@
 2002-10-30  Darin Adler  <darin at apple.com>
 
+	- fixed memory leaks in plugin package creation code
+
+        * Plugins.subproj/WebNetscapePluginPackage.m:
+        (-[WebNetscapePluginPackage initWithPath:]): Rearrange this code, and make sure
+	that it does a [self release] if it's going to return nil instead of self.
+        (-[WebNetscapePluginPackage unload]): Set bundle to 0 when we release it.
+        (-[WebNetscapePluginPackage dealloc]): Release the bundle if it's not 0.
+
+        * Plugins.subproj/WebPluginPackage.m:
+        (-[WebPluginPackage initWithPath:]): Rearrange this code, and make sure
+	that it does a [self release] if it's going to return nil instead of self.
+
+2002-10-30  Darin Adler  <darin at apple.com>
+
 	- fixed 3086564 -- REGRESSION: meta-refresh to the same page doesn't refresh
 
 	The key is to respect the new reload: parameter from the bridge.
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginPackage.m b/WebKit/Plugins.subproj/WebNetscapePluginPackage.m
index 4539592..54bf199 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginPackage.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginPackage.m
@@ -162,48 +162,54 @@ TransitionVector tVectorForFunctionPointer(FunctionPointer);
     
     [self setPath:thePath];
     
-    NSFileManager *fileManager = [NSFileManager defaultManager];
-    NSDictionary *fileInfo = [fileManager fileAttributesAtPath:thePath traverseLink:YES];
-    UInt32 type;
+    NSDictionary *fileInfo = [[NSFileManager defaultManager] fileAttributesAtPath:thePath traverseLink:YES];
+    UInt32 type = 0;
 
+    // bundle
+    if ([[fileInfo objectForKey:NSFileType] isEqualToString:NSFileTypeDirectory]) {
+        bundle = CFBundleCreate(NULL, (CFURLRef)[NSURL fileURLWithPath:thePath]);
+        if (bundle) {
+            isBundle = YES;
+            CFBundleGetPackageInfo(bundle, &type, NULL);
+        }
+    }
+    
+#ifdef __ppc__
     // single-file plug-in with resource fork
-    if([[fileInfo objectForKey:@"NSFileType"] isEqualToString:@"NSFileTypeRegular"]){
-        type = [[fileInfo objectForKey:@"NSFileHFSTypeCode"] unsignedLongValue];
+    if ([[fileInfo objectForKey:NSFileType] isEqualToString:NSFileTypeRegular]) {
+        type = [[fileInfo objectForKey:NSFileHFSTypeCode] unsignedLongValue];
         isBundle = NO;
-#ifndef __ppc__
-        return nil;
+    }
 #endif
-    // bundle
-    }else if([[fileInfo objectForKey:@"NSFileType"] isEqualToString:@"NSFileTypeDirectory"]){
-        bundle = CFBundleCreate(NULL, (CFURLRef)[NSURL fileURLWithPath:thePath]);        
-        CFBundleGetPackageInfo(bundle, &type, NULL);
 
-        // Check if the executable is mach-o or CFM
+    if (type != FOUR_CHAR_CODE('BRPL') && type != FOUR_CHAR_CODE('IEPL')) {
+        [self release];
+        return nil;
+    }
+
+    // Check if the executable is Mach-O or CFM.
+    if (bundle) {
         NSURL *executableURL = (NSURL *)CFBundleCopyExecutableURL(bundle);
         NSFileHandle *executableFile = [NSFileHandle fileHandleForReadingAtPath:[executableURL path]];
         [executableURL release];
-        
         NSData *data = [executableFile readDataOfLength:8];
         [executableFile closeFile];
-        if(!memcmp([data bytes], "Joy!peff", 8)){
-            isCFM = TRUE;
-#ifndef __ppc__
+        if (!data) {
+            [self release];
             return nil;
-#endif
-        }else{
-            isCFM = FALSE;
         }
-        
-        isBundle = YES;
-    }else{
-        return nil;
-    }
-    
-    if(type == FOUR_CHAR_CODE('BRPL') || type == FOUR_CHAR_CODE('IEPL') ){
-        if(![self getMIMEInformation]){
+        isCFM = memcmp([data bytes], "Joy!peff", 8) == 0;
+#ifndef __ppc__
+        // CFM is PPC-only.
+        if (isCFM) {
+            [self release];
             return nil;
         }
-    }else{
+#endif
+    }
+
+    if (![self getMIMEInformation]) {
+        [self release];
         return nil;
     }
 
@@ -388,6 +394,7 @@ TransitionVector tVectorForFunctionPointer(FunctionPointer);
     if(isBundle){
         CFBundleUnloadExecutable(bundle);
         CFRelease(bundle);
+        bundle = 0;
     }else{
         CloseConnection(&connID);
     }
@@ -395,6 +402,14 @@ TransitionVector tVectorForFunctionPointer(FunctionPointer);
     isLoaded = FALSE;
 }
 
+- (void)dealloc
+{
+    if (bundle) {
+        CFRelease(bundle);
+    }
+    [super dealloc];
+}
+
 - (NPP_SetWindowProcPtr)NPP_SetWindow
 {
     return NPP_SetWindow;
diff --git a/WebKit/Plugins.subproj/WebPluginPackage.m b/WebKit/Plugins.subproj/WebPluginPackage.m
index fb983bd..84c9f79 100644
--- a/WebKit/Plugins.subproj/WebPluginPackage.m
+++ b/WebKit/Plugins.subproj/WebPluginPackage.m
@@ -72,21 +72,28 @@
 {
     [super initWithPath:pluginPath];
     
-    bundle = [[NSBundle alloc] initWithPath:pluginPath];
-
-    if(!bundle){
+    UInt32 type = 0;
+    CFBundleRef coreFoundationBundle = CFBundleCreate(NULL, (CFURLRef)[NSURL fileURLWithPath:pluginPath]);        
+    if (coreFoundationBundle) {
+        CFBundleGetPackageInfo(coreFoundationBundle, &type, NULL);
+        CFRelease(coreFoundationBundle);
+    }
+    
+    if (type != FOUR_CHAR_CODE('WBPL')) {
+        [self release];
         return nil;
     }
 
-    UInt32 type;
-    CFBundleRef theBundle = CFBundleCreate(NULL, (CFURLRef)[NSURL fileURLWithPath:pluginPath]);        
-    CFBundleGetPackageInfo(theBundle, &type, NULL);
-    CFRelease(theBundle);
+    bundle = [[NSBundle alloc] initWithPath:pluginPath];
+    if (!bundle) {
+        [self release];
+        return nil;
+    }
 
     [self setPath:pluginPath];
-    
-    if(type != FOUR_CHAR_CODE('WBPL') || ![self getMIMEInformation]){
-        [bundle release];
+
+    if (![self getMIMEInformation]) {
+        [self release];
         return nil;
     }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list