[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

mitz at apple.com mitz at apple.com
Thu Oct 29 20:35:15 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 81213daa3e9864a7cf7ff0e4cff4502d1186a4dc
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Sep 28 20:55:38 2009 +0000

    <rdar://problem/7240911> REGRESSION (r48586): Crash occurs when loading
    a PDF
    
    Reviewed by Anders Carlsson.
    
    CGPDFObjectRef is not a CFTypeRef, and cannot be retained or released.
    Its lifetime is managed by its container. Just use a Vector to store
    CGPDFObjectRefs, relying on the CGPDFDocument to keep them alive.
    
    * WebView/WebPDFDocumentExtras.mm:
    (appendValuesInPDFNameSubtreeToVector):
    (getAllValuesInPDFNameTree):
    (web_PDFDocumentAllScripts):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48831 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 7f97f0c..38c074a 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,19 @@
+2009-09-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        <rdar://problem/7240911> REGRESSION (r48586): Crash occurs when loading
+        a PDF
+
+        CGPDFObjectRef is not a CFTypeRef, and cannot be retained or released.
+        Its lifetime is managed by its container. Just use a Vector to store
+        CGPDFObjectRefs, relying on the CGPDFDocument to keep them alive.
+
+        * WebView/WebPDFDocumentExtras.mm:
+        (appendValuesInPDFNameSubtreeToVector):
+        (getAllValuesInPDFNameTree):
+        (web_PDFDocumentAllScripts):
+
 2009-09-24  Jon Honeycutt  <jhoneycutt at apple.com>
 
         Reviewed by Alice Liu.
diff --git a/WebKit/mac/WebView/WebPDFDocumentExtras.mm b/WebKit/mac/WebView/WebPDFDocumentExtras.mm
index 9253a5d..ec580ec 100644
--- a/WebKit/mac/WebView/WebPDFDocumentExtras.mm
+++ b/WebKit/mac/WebView/WebPDFDocumentExtras.mm
@@ -26,6 +26,7 @@
 #import "WebPDFDocumentExtras.h"
 
 #import "WebTypesInternal.h"
+#import <JavaScriptCore/Vector.h>
 #import <JavaScriptCore/RetainPtr.h>
 #import <PDFKit/PDFDocument.h>
 #import <objc/objc-runtime.h>
@@ -36,7 +37,7 @@
 @end
 #endif
 
-static void appendValuesInPDFNameSubtreeToArray(CGPDFDictionaryRef subtree, NSMutableArray *values)
+static void appendValuesInPDFNameSubtreeToVector(CGPDFDictionaryRef subtree, Vector<CGPDFObjectRef>& values)
 {
     CGPDFArrayRef names;
     if (CGPDFDictionaryGetArray(subtree, "Names", &names)) {
@@ -44,7 +45,7 @@ static void appendValuesInPDFNameSubtreeToArray(CGPDFDictionaryRef subtree, NSMu
         for (size_t i = 0; i < nameCount; ++i) {
             CGPDFObjectRef object;
             CGPDFArrayGetObject(names, 2 * i + 1, &object);
-            [values addObject:(id)object];
+            values.append(object);
         }
         return;
     }
@@ -58,15 +59,13 @@ static void appendValuesInPDFNameSubtreeToArray(CGPDFDictionaryRef subtree, NSMu
         CGPDFDictionaryRef kid;
         if (!CGPDFArrayGetDictionary(kids, i, &kid))
             continue;
-        appendValuesInPDFNameSubtreeToArray(kid, values);
+        appendValuesInPDFNameSubtreeToVector(kid, values);
     }
 }
 
-static NSArray *allValuesInPDFNameTree(CGPDFDictionaryRef tree)
+static void getAllValuesInPDFNameTree(CGPDFDictionaryRef tree, Vector<CGPDFObjectRef>& allValues)
 {
-    NSMutableArray *allValues = [[NSMutableArray alloc] init];
-    appendValuesInPDFNameSubtreeToArray(tree, allValues);
-    return [allValues autorelease];
+    appendValuesInPDFNameSubtreeToVector(tree, allValues);
 }
 
 static NSArray *web_PDFDocumentAllScripts(id self, SEL _cmd)
@@ -91,12 +90,13 @@ static NSArray *web_PDFDocumentAllScripts(id self, SEL _cmd)
         return scripts;
 
     // The names are aribtrary. We are only interested in the values.
-    NSArray *objects = allValuesInPDFNameTree(javaScriptNameTree);
-    NSUInteger objectCount = [objects count];
+    Vector<CGPDFObjectRef> objects;
+    getAllValuesInPDFNameTree(javaScriptNameTree, objects);
+    size_t objectCount = objects.size();
 
-    for (NSUInteger i = 0; i < objectCount; ++i) {
+    for (size_t i = 0; i < objectCount; ++i) {
         CGPDFDictionaryRef javaScriptAction;
-        if (!CGPDFObjectGetValue(reinterpret_cast<CGPDFObjectRef>([objects objectAtIndex:i]), kCGPDFObjectTypeDictionary, &javaScriptAction))
+        if (!CGPDFObjectGetValue(reinterpret_cast<CGPDFObjectRef>(objects[i]), kCGPDFObjectTypeDictionary, &javaScriptAction))
             continue;
 
         // A JavaScript action must have an action type of "JavaScript".

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list