Title: [287017] trunk/Source/WebCore
Revision
287017
Author
[email protected]
Date
2021-12-14 01:35:38 -0800 (Tue, 14 Dec 2021)

Log Message

Null pointer crash in FetchResponse::clone
https://bugs.webkit.org/show_bug.cgi?id=234236
<rdar://86327601>

Reviewed by Alex Christensen.

>From the log, we are most probably getting a null globalObject from a ScriptExecutionContext in FetchResponse::clone.
This may happen in case the document is navigated away but we still execute some code for it.
Add a null check to ensure we do not crash.

* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::clone):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287016 => 287017)


--- trunk/Source/WebCore/ChangeLog	2021-12-14 09:03:03 UTC (rev 287016)
+++ trunk/Source/WebCore/ChangeLog	2021-12-14 09:35:38 UTC (rev 287017)
@@ -1,3 +1,18 @@
+2021-12-14  Youenn Fablet  <[email protected]>
+
+        Null pointer crash in FetchResponse::clone
+        https://bugs.webkit.org/show_bug.cgi?id=234236
+        <rdar://86327601>
+
+        Reviewed by Alex Christensen.
+
+        From the log, we are most probably getting a null globalObject from a ScriptExecutionContext in FetchResponse::clone.
+        This may happen in case the document is navigated away but we still execute some code for it.
+        Add a null check to ensure we do not crash.
+
+        * Modules/fetch/FetchResponse.cpp:
+        (WebCore::FetchResponse::clone):
+
 2021-12-14  Ben Nham  <[email protected]>
 
         Add web push message decryption routines

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (287016 => 287017)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2021-12-14 09:03:03 UTC (rev 287016)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2021-12-14 09:35:38 UTC (rev 287017)
@@ -182,7 +182,11 @@
 
     // If loading, let's create a stream so that data is teed on both clones.
     if (isLoading() && !m_readableStreamSource) {
-        auto voidOrException = createReadableStream(*context.globalObject());
+        auto* globalObject = context.globalObject();
+        if (!globalObject)
+            return Exception { InvalidStateError, "Context is stopped"_s };
+
+        auto voidOrException = createReadableStream(*globalObject);
         if (UNLIKELY(voidOrException.hasException()))
             return voidOrException.releaseException();
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to