Title: [288210] releases/WebKitGTK/webkit-2.34/Source/WebCore
Revision
288210
Author
[email protected]
Date
2022-01-19 09:15:08 -0800 (Wed, 19 Jan 2022)

Log Message

Merge r282241 - Potential crash under CachedRawResource::didAddClient()
https://bugs.webkit.org/show_bug.cgi?id=230121
<rdar://82936913>

Reviewed by Alex Christensen.

In r280083, I tried to address this crash by holding a strong reference
to the SharedBuffer before calling forEachSegment() on it. However, the
crash is still happening after this fix.

My suspicion is that the SharedBuffer's internal m_segments vector gets
modified as we iterate over it. As a result, I am reverting r280083 and
iterating over a copy of m_segments in forEachSegment() instead.

No new tests, we haven't been able to reproduce.

* WebCore.xcodeproj/project.pbxproj:
* loader/cache/CachedRawResource.cpp:
(WebCore::CachedRawResource::didAddClient):
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::forEachSegment const):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog (288209 => 288210)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog	2022-01-19 17:15:02 UTC (rev 288209)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog	2022-01-19 17:15:08 UTC (rev 288210)
@@ -1,3 +1,27 @@
+2021-09-09  Chris Dumez  <[email protected]>
+
+        Potential crash under CachedRawResource::didAddClient()
+        https://bugs.webkit.org/show_bug.cgi?id=230121
+        <rdar://82936913>
+
+        Reviewed by Alex Christensen.
+
+        In r280083, I tried to address this crash by holding a strong reference
+        to the SharedBuffer before calling forEachSegment() on it. However, the
+        crash is still happening after this fix.
+
+        My suspicion is that the SharedBuffer's internal m_segments vector gets
+        modified as we iterate over it. As a result, I am reverting r280083 and
+        iterating over a copy of m_segments in forEachSegment() instead.
+
+        No new tests, we haven't been able to reproduce.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/cache/CachedRawResource.cpp:
+        (WebCore::CachedRawResource::didAddClient):
+        * platform/SharedBuffer.cpp:
+        (WebCore::SharedBuffer::forEachSegment const):
+
 2021-09-07  Rob Buis  <[email protected]>
 
         Nullptr crash in DeleteSelectionCommand::removeNodeUpdatingStates

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/loader/cache/CachedRawResource.cpp (288209 => 288210)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/loader/cache/CachedRawResource.cpp	2022-01-19 17:15:02 UTC (rev 288209)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/loader/cache/CachedRawResource.cpp	2022-01-19 17:15:08 UTC (rev 288210)
@@ -167,8 +167,8 @@
         auto responseProcessedHandler = [this, protectedThis = WTFMove(protectedThis), client] {
             if (!hasClient(*client))
                 return;
-            if (auto data = "" {
-                data->forEachSegment([&](auto& segment) {
+            if (m_data) {
+                m_data->forEachSegment([&](auto& segment) {
                     if (hasClient(*client))
                         client->dataReceived(*this, segment.data(), segment.size());
                 });

Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/SharedBuffer.cpp (288209 => 288210)


--- releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/SharedBuffer.cpp	2022-01-19 17:15:02 UTC (rev 288209)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/platform/SharedBuffer.cpp	2022-01-19 17:15:08 UTC (rev 288210)
@@ -238,7 +238,8 @@
 
 void SharedBuffer::forEachSegment(const Function<void(const Span<const uint8_t>&)>& apply) const
 {
-    for (auto& segment : m_segments)
+    auto segments = m_segments;
+    for (auto& segment : segments)
         apply(Span { segment.segment->data(), segment.segment->size() });
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to