2010-10-27 David Kilzer <ddkilzer@apple.com>
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Oct 2010 15:43:31 +0000 (15:43 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Oct 2010 15:43:31 +0000 (15:43 +0000)
        Fix leak of CFMutableDictionaryRef in createXMLStringFromWebArchiveData()

        Reviewed by Adam Roben.

        Follow-up fix for: <https://bugs.webkit.org/show_bug.cgi?id=48278>

        * DumpRenderTree/cf/WebArchiveDumpSupport.cpp:
        (createXMLStringFromWebArchiveData): Use RetainPtr<> to fix a
        leak introduced in r70613.

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

WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/cf/WebArchiveDumpSupport.cpp

index 7d92969..0179bb3 100644 (file)
@@ -1,3 +1,15 @@
+2010-10-27  David Kilzer  <ddkilzer@apple.com>
+
+        Fix leak of CFMutableDictionaryRef in createXMLStringFromWebArchiveData()
+
+        Reviewed by Adam Roben.
+
+        Follow-up fix for: <https://bugs.webkit.org/show_bug.cgi?id=48278>
+
+        * DumpRenderTree/cf/WebArchiveDumpSupport.cpp:
+        (createXMLStringFromWebArchiveData): Use RetainPtr<> to fix a
+        leak introduced in r70613.
+
 2010-10-27  Gabor Rapcsanyi  <rgabor@inf.u-szeged.hu>
 
         Reviewed by Csaba Osztrogon√°c.
index 2409282..4d77454 100644 (file)
@@ -161,10 +161,10 @@ CFStringRef createXMLStringFromWebArchiveData(CFDataRef webArchiveData)
     CFIndex bytesCount = CFDataGetLength(webArchiveData);
     RetainPtr<CFReadStreamRef> readStream(AdoptCF, CFReadStreamCreateWithBytesNoCopy(kCFAllocatorDefault, CFDataGetBytePtr(webArchiveData), bytesCount, kCFAllocatorNull));
     CFReadStreamOpen(readStream.get());
-    CFMutableDictionaryRef propertyList = (CFMutableDictionaryRef)CFPropertyListCreateFromStream(kCFAllocatorDefault, readStream.get(), bytesCount, kCFPropertyListMutableContainersAndLeaves, &format, 0);
+    RetainPtr<CFMutableDictionaryRef> propertyList(AdoptCF, (CFMutableDictionaryRef)CFPropertyListCreateFromStream(kCFAllocatorDefault, readStream.get(), bytesCount, kCFPropertyListMutableContainersAndLeaves, &format, 0));
     CFReadStreamClose(readStream.get());
 #else
-    CFMutableDictionaryRef propertyList = (CFMutableDictionaryRef)CFPropertyListCreateWithData(kCFAllocatorDefault, webArchiveData, kCFPropertyListMutableContainersAndLeaves, &format, &error);
+    RetainPtr<CFMutableDictionaryRef> propertyList(AdoptCF, (CFMutableDictionaryRef)CFPropertyListCreateWithData(kCFAllocatorDefault, webArchiveData, kCFPropertyListMutableContainersAndLeaves, &format, &error));
 #endif
 
     if (!propertyList) {
@@ -174,7 +174,7 @@ CFStringRef createXMLStringFromWebArchiveData(CFDataRef webArchiveData)
     }
 
     RetainPtr<CFMutableArrayRef> resources(AdoptCF, CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks));
-    CFArrayAppendValue(resources.get(), propertyList);
+    CFArrayAppendValue(resources.get(), propertyList.get());
 
     while (CFArrayGetCount(resources.get())) {
         RetainPtr<CFMutableDictionaryRef> resourcePropertyList = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(resources.get(), 0);
@@ -208,9 +208,9 @@ CFStringRef createXMLStringFromWebArchiveData(CFDataRef webArchiveData)
     error = 0;
 
 #if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
-    RetainPtr<CFDataRef> xmlData(AdoptCF, CFPropertyListCreateXMLData(kCFAllocatorDefault, propertyList));
+    RetainPtr<CFDataRef> xmlData(AdoptCF, CFPropertyListCreateXMLData(kCFAllocatorDefault, propertyList.get()));
 #else
-    RetainPtr<CFDataRef> xmlData(AdoptCF, CFPropertyListCreateData(kCFAllocatorDefault, propertyList, kCFPropertyListXMLFormat_v1_0, 0, &error));
+    RetainPtr<CFDataRef> xmlData(AdoptCF, CFPropertyListCreateData(kCFAllocatorDefault, propertyList.get(), kCFPropertyListXMLFormat_v1_0, 0, &error));
 #endif
 
     if (!xmlData) {