2006-10-07 Mark Rowe <bdash@webkit.org>
authorbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Oct 2006 10:42:47 +0000 (10:42 +0000)
committerbdash <bdash@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Oct 2006 10:42:47 +0000 (10:42 +0000)
        Reviewed by Mitz.

        Fix memory leak from -[WebDocumentLoadState setTitle:].

        * Loader/WebDocumentLoadState.m:
        (-[WebDocumentLoadState setTitle:]): Ensure 'trimmed' is released even when length is
        zero, and untangle the confusing logic around this case.

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

WebKit/ChangeLog
WebKit/Loader/WebDocumentLoadState.m

index 9057cc8bbcf257e33e5f170a78c7963c2a9c2778..25df98807c0d20645129568cc325e4523dc48f24 100644 (file)
@@ -1,3 +1,13 @@
+2006-10-07  Mark Rowe  <bdash@webkit.org>
+
+        Reviewed by Mitz.
+
+        Fix memory leak from -[WebDocumentLoadState setTitle:].
+
+        * Loader/WebDocumentLoadState.m:
+        (-[WebDocumentLoadState setTitle:]): Ensure 'trimmed' is released even when length is
+        zero, and untangle the confusing logic around this case.
+
 2006-10-06  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Darin
index 2ded3cd349ae84e72f460655e5cdd55893f08a64..0e0ba60004ad1550f83d0c4308c466fd1c180b47 100644 (file)
 
 - (void)setTitle:(NSString *)title
 {
-    NSString *trimmed;
-    if (title == nil) {
-        trimmed = nil;
-    } else {
+    NSString *trimmed = nil;
+    if (title) {
         trimmed = [title mutableCopy];
         CFStringTrimWhitespace((CFMutableStringRef)trimmed);
-        if ([trimmed length] == 0)
+        if ([trimmed length] == 0) {
+            [trimmed release];
             trimmed = nil;
+        }
     }
-    if (trimmed == nil) {
-        if (pageTitle == nil)
-            return;
-    } else {
-        if ([pageTitle isEqualToString:trimmed])
-            return;
-    }
-    
-    if (!trimmed || [trimmed length] == 0)
+
+    if (!trimmed)
+        return;
+
+    if ([pageTitle isEqualToString:trimmed])
         return;
 
     [frameLoader willChangeTitleForDocumentLoadState:self];