Reviewed by Adele.
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Mar 2005 00:10:41 +0000 (00:10 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Mar 2005 00:10:41 +0000 (00:10 +0000)
        - fixed <rdar://problem/4023337> Safari stops loading any page (-[NSCFDictionary setObject:forKey:]:
        attempt to insert nil key)

        It is very likely that the exception being hit is caused by the same problem as WebFoundation
        bug 4018486. This change makes the code robust against this kind of problem regardless.

        * WebView.subproj/WebBaseResourceHandleDelegate.m:
        (-[WebBaseResourceHandleDelegate saveResource]):
        Don't call addSubresource if newly-created resource is nil (but do assert on debug builds).
        Also assert that originalURL and MIMEType are not nil.

        * WebView.subproj/WebDataSource.m:
        (-[WebDataSource addSubresource:]):
        Don't add nil subresource to dictionary, but do assert on debug builds.

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

WebKit/ChangeLog
WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
WebKit/WebView.subproj/WebDataSource.m
WebKit/WebView.subproj/WebLoader.m

index 88a8829e4a24ad0099992fe6de0056b266bc3fd4..78c17ebd9326bdc9b3eb901677a551ff21b279bb 100644 (file)
@@ -1,3 +1,22 @@
+2005-03-02  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Adele.
+        
+        - fixed <rdar://problem/4023337> Safari stops loading any page (-[NSCFDictionary setObject:forKey:]: 
+        attempt to insert nil key)
+        
+        It is very likely that the exception being hit is caused by the same problem as WebFoundation
+        bug 4018486. This change makes the code robust against this kind of problem regardless.
+
+        * WebView.subproj/WebBaseResourceHandleDelegate.m:
+        (-[WebBaseResourceHandleDelegate saveResource]):
+        Don't call addSubresource if newly-created resource is nil (but do assert on debug builds).
+        Also assert that originalURL and MIMEType are not nil.
+        
+        * WebView.subproj/WebDataSource.m:
+        (-[WebDataSource addSubresource:]):
+        Don't add nil subresource to dictionary, but do assert on debug builds.
+
 === Safari-401 ===
 
 2005-03-01  John Sullivan  <sullivan@apple.com>
index 8cd77af8e3abdd9dd52cd28e8ef1b1fc2d49c581..91f24b1453171c4416b61f316a84f99028adbf23 100644 (file)
@@ -300,14 +300,20 @@ static BOOL NSURLConnectionSupportsBufferedData;
         NSData *data = [self resourceData];
         if ([data length] > 0) {
             // Don't have WebResource copy the data since the data is a NSMutableData that we know won't get modified. 
+            ASSERT(originalURL);
+            ASSERT([response MIMEType]);
             WebResource *newResource = [[WebResource alloc] _initWithData:data
                                                                       URL:originalURL
                                                                  MIMEType:[response MIMEType]
                                                          textEncodingName:[response textEncodingName]
                                                                 frameName:nil
                                                                  copyData:NO];
-            [dataSource addSubresource:newResource];
-            [newResource release];
+            if (newResource != nil) {
+                [dataSource addSubresource:newResource];
+                [newResource release];
+            } else {
+                ASSERT_NOT_REACHED();
+            }
         }
     }
 }
index b97d47fc310ac9db5f06c5dcad6aa0ab671b0e57..151d6ab88acd24cb7cf77eb83532eeadb9fe4eaf 100644 (file)
 
 - (void)addSubresource:(WebResource *)subresource
 {
-    [_private->subresources setObject:subresource forKey:[[subresource URL] _web_originalDataAsString]];
+    if (subresource) {
+        [_private->subresources setObject:subresource forKey:[[subresource URL] _web_originalDataAsString]];
+    } else {
+        ASSERT_NOT_REACHED();
+    }
 }
 
 @end
index 8cd77af8e3abdd9dd52cd28e8ef1b1fc2d49c581..91f24b1453171c4416b61f316a84f99028adbf23 100644 (file)
@@ -300,14 +300,20 @@ static BOOL NSURLConnectionSupportsBufferedData;
         NSData *data = [self resourceData];
         if ([data length] > 0) {
             // Don't have WebResource copy the data since the data is a NSMutableData that we know won't get modified. 
+            ASSERT(originalURL);
+            ASSERT([response MIMEType]);
             WebResource *newResource = [[WebResource alloc] _initWithData:data
                                                                       URL:originalURL
                                                                  MIMEType:[response MIMEType]
                                                          textEncodingName:[response textEncodingName]
                                                                 frameName:nil
                                                                  copyData:NO];
-            [dataSource addSubresource:newResource];
-            [newResource release];
+            if (newResource != nil) {
+                [dataSource addSubresource:newResource];
+                [newResource release];
+            } else {
+                ASSERT_NOT_REACHED();
+            }
         }
     }
 }