Title: [226919] trunk/Source/WebCore
Revision
226919
Author
[email protected]
Date
2018-01-12 15:35:55 -0800 (Fri, 12 Jan 2018)

Log Message

[Cocoa] CTFontCopyDefaultCascadeListForLanguages() can return nullptr
https://bugs.webkit.org/show_bug.cgi?id=181615
<rdar://problem/36334637>

Reviewed by Jon Lee.

Speculative fix. We are getting crash reports saying that this call can return nullptr, and we
don't check for it.

No new tests because I couldn't find the specific input that causes it to return nullptr. (I
tried running this code with every 0, 1, and 2 length locale string, every weight value, and
every italic value, and couldn't get it to crash. I also inspected the code to figure out what
values would cause it to return nullptr, and I couldn't find anything other than if the system
has a totally busted font setup.)

* platform/graphics/cocoa/FontDescriptionCocoa.cpp:
(WebCore::SystemFontDatabase::computeCascadeList):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (226918 => 226919)


--- trunk/Source/WebCore/ChangeLog	2018-01-12 23:29:04 UTC (rev 226918)
+++ trunk/Source/WebCore/ChangeLog	2018-01-12 23:35:55 UTC (rev 226919)
@@ -1,3 +1,23 @@
+2018-01-12  Myles C. Maxfield  <[email protected]>
+
+        [Cocoa] CTFontCopyDefaultCascadeListForLanguages() can return nullptr
+        https://bugs.webkit.org/show_bug.cgi?id=181615
+        <rdar://problem/36334637>
+
+        Reviewed by Jon Lee.
+
+        Speculative fix. We are getting crash reports saying that this call can return nullptr, and we
+        don't check for it.
+
+        No new tests because I couldn't find the specific input that causes it to return nullptr. (I
+        tried running this code with every 0, 1, and 2 length locale string, every weight value, and
+        every italic value, and couldn't get it to crash. I also inspected the code to figure out what
+        values would cause it to return nullptr, and I couldn't find anything other than if the system
+        has a totally busted font setup.)
+
+        * platform/graphics/cocoa/FontDescriptionCocoa.cpp:
+        (WebCore::SystemFontDatabase::computeCascadeList):
+
 2018-01-11  Dean Jackson  <[email protected]>
 
         [WebGL] Simulated vertexAttrib0 can sometimes cause OUT_OF_MEMORY errors

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp (226918 => 226919)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp	2018-01-12 23:29:04 UTC (rev 226918)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp	2018-01-12 23:35:55 UTC (rev 226919)
@@ -181,9 +181,11 @@
         Vector<RetainPtr<CTFontDescriptorRef>> result;
         // WebKit handles the cascade list, and WebKit 2's IPC code doesn't know how to serialize Core Text's cascade list.
         result.append(removeCascadeList(adoptCF(CTFontCopyFontDescriptor(font)).get()));
-        CFIndex arrayLength = CFArrayGetCount(cascadeList.get());
-        for (CFIndex i = 0; i < arrayLength; ++i)
-            result.append(static_cast<CTFontDescriptorRef>(CFArrayGetValueAtIndex(cascadeList.get(), i)));
+        if (cascadeList) {
+            CFIndex arrayLength = CFArrayGetCount(cascadeList.get());
+            for (CFIndex i = 0; i < arrayLength; ++i)
+                result.append(static_cast<CTFontDescriptorRef>(CFArrayGetValueAtIndex(cascadeList.get(), i)));
+        }
         return result;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to