[Font Loading] Crash when a single load request causes multiple fonts to fail loading
[WebKit-https.git] / Source / WebCore / css / FontFaceSet.cpp
index ad5aa48..3f9f58b 100644 (file)
@@ -236,12 +236,16 @@ void FontFaceSet::faceFinished(CSSFontFace& face, CSSFontFace::Status newStatus)
 
     for (auto& pendingPromise : iterator->value) {
         if (newStatus == CSSFontFace::Status::Success) {
-            if (pendingPromise->hasOneRef())
+            if (pendingPromise->hasOneRef() && !pendingPromise->hasReachedTerminalState) {
                 pendingPromise->promise.resolve(pendingPromise->faces);
+                pendingPromise->hasReachedTerminalState = true;
+            }
         } else {
             ASSERT(newStatus == CSSFontFace::Status::Failure);
-            // The first resolution wins, so we can just reject early now.
-            pendingPromise->promise.reject(DOMCoreException::create(ExceptionCodeDescription(NETWORK_ERR)));
+            if (!pendingPromise->hasReachedTerminalState) {
+                pendingPromise->promise.reject(DOMCoreException::create(ExceptionCodeDescription(NETWORK_ERR)));
+                pendingPromise->hasReachedTerminalState = true;
+            }
         }
     }