<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[286408] trunk/Source/WebKit</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/286408">286408</a></dd>
<dt>Author</dt> <dd>jya@apple.com</dd>
<dt>Date</dt> <dd>2021-12-01 18:12:37 -0800 (Wed, 01 Dec 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Avoid allocating and copy memory from a SharedMemory into a SharedBuffer
https://bugs.webkit.org/show_bug.cgi?id=233401
rdar://85637721

Reviewed by Eric Carlson.

We can directly wrap a SharedMemory into a SharedBuffer using
SharedMemory::createSharedBuffer instead.
No change in observable behaviour other than total memory size reduction.

Fly-by fix: check for null when mapping a SharedMemory to an IPC handle
in a couple of spots.

* Shared/ShareableResource.h: Make ShareableResource use thread-safe refcount.
A ShareableResource once created is immutable and the SharedMemory object
itself has thread-safe refounting. Deleting the object outside the main thread
is safe.
Make members const.
* Shared/ShareableResource.cpp:
(WebKit::ShareableResource::wrapInSharedBuffer): Refactor method, using DataSegment::Provider
instead of platfom specific code.
* Shared/WebCoreArgumentCoders.cpp:
(IPC::decodeSharedBuffer):
* UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
(WebKit::WebPasteboardProxy::setPasteboardBufferForType):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::saveImageToLibrary):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::dataSelectionForPasteboard):
(WebKit::WebPageProxy::setPromisedDataForImage):
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::bufferForType):
Hardening code, checking for nullability.
(WebKit::WebPlatformStrategies::readBufferFromPasteboard):
Hardening code, checking for nullability.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::restoreAppHighlightsAndScrollToIndex):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitSharedShareableResourcecpp">trunk/Source/WebKit/Shared/ShareableResource.cpp</a></li>
<li><a href="#trunkSourceWebKitSharedShareableResourceh">trunk/Source/WebKit/Shared/ShareableResource.h</a></li>
<li><a href="#trunkSourceWebKitSharedWebCoreArgumentCoderscpp">trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaWebPasteboardProxyCocoamm">trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWebPageProxyIOSmm">trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessmacWebPageProxyMacmm">trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebPlatformStrategiescpp">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (286407 => 286408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-12-02 02:10:30 UTC (rev 286407)
+++ trunk/Source/WebKit/ChangeLog       2021-12-02 02:12:37 UTC (rev 286408)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2021-12-01  Jean-Yves Avenard  <jya@apple.com>
+
+        Avoid allocating and copy memory from a SharedMemory into a SharedBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=233401
+        rdar://85637721
+
+        Reviewed by Eric Carlson.
+
+        We can directly wrap a SharedMemory into a SharedBuffer using
+        SharedMemory::createSharedBuffer instead.
+        No change in observable behaviour other than total memory size reduction.
+
+        Fly-by fix: check for null when mapping a SharedMemory to an IPC handle
+        in a couple of spots.
+
+        * Shared/ShareableResource.h: Make ShareableResource use thread-safe refcount.
+        A ShareableResource once created is immutable and the SharedMemory object
+        itself has thread-safe refounting. Deleting the object outside the main thread
+        is safe.
+        Make members const.
+        * Shared/ShareableResource.cpp:
+        (WebKit::ShareableResource::wrapInSharedBuffer): Refactor method, using DataSegment::Provider
+        instead of platfom specific code.
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::decodeSharedBuffer):
+        * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
+        (WebKit::WebPasteboardProxy::setPasteboardBufferForType):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::saveImageToLibrary):
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::dataSelectionForPasteboard):
+        (WebKit::WebPageProxy::setPromisedDataForImage):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::bufferForType):
+        Hardening code, checking for nullability.
+        (WebKit::WebPlatformStrategies::readBufferFromPasteboard):
+        Hardening code, checking for nullability.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::restoreAppHighlightsAndScrollToIndex):
+
</ins><span class="cx"> 2021-12-01  Chris Fleizach  <cfleizach@apple.com>
</span><span class="cx"> 
</span><span class="cx">         AX: Support accessibility attributes for <model>
</span></span></pre></div>
<a id="trunkSourceWebKitSharedShareableResourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/ShareableResource.cpp (286407 => 286408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/ShareableResource.cpp 2021-12-02 02:10:30 UTC (rev 286407)
+++ trunk/Source/WebKit/Shared/ShareableResource.cpp    2021-12-02 02:12:37 UTC (rev 286408)
</span><span class="lines">@@ -55,46 +55,12 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if USE(CF)
-static void shareableResourceDeallocate(void *ptr, void *info)
-{
-    static_cast<ShareableResource*>(info)->deref(); // Balanced by ref() in createShareableResourceDeallocator()
-}
-    
-static RetainPtr<CFAllocatorRef> createShareableResourceDeallocator(ShareableResource* resource)
-{
-    CFAllocatorContext context = { 0,
-        resource,
-        NULL, // retain
-        NULL, // release
-        NULL, // copyDescription
-        NULL, // allocate
-        NULL, // reallocate
-        shareableResourceDeallocate,
-        NULL, // preferredSize
-    };
-
-    return adoptCF(CFAllocatorCreate(kCFAllocatorDefault, &context));
-}
-#endif
-
</del><span class="cx"> RefPtr<SharedBuffer> ShareableResource::wrapInSharedBuffer()
</span><span class="cx"> {
</span><del>-    ref(); // Balanced by deref when SharedBuffer is deallocated.
-
-#if USE(CF)
-    auto deallocator = createShareableResourceDeallocator(this);
-    auto cfData = adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, data(), static_cast<CFIndex>(size()), deallocator.get()));
-    return SharedBuffer::create(cfData.get());
-#elif USE(GLIB)
-    GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new_with_free_func(data(), size(), [](void* data) {
-        static_cast<ShareableResource*>(data)->deref();
-    }, this));
-    return SharedBuffer::create(bytes.get());
-#else
-    ASSERT_NOT_REACHED();
-    return nullptr;
-#endif
</del><ins>+    return SharedBuffer::create(SharedBuffer::DataSegment::Provider {
+        [self = Ref { *this }]() { return self->data(); },
+        [self = Ref { *this }]() { return self->size(); }
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RefPtr<SharedBuffer> ShareableResource::Handle::tryWrapInSharedBuffer() const
</span><span class="lines">@@ -138,9 +104,7 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ShareableResource::~ShareableResource()
-{
-}
</del><ins>+ShareableResource::~ShareableResource() = default;
</ins><span class="cx"> 
</span><span class="cx"> bool ShareableResource::createHandle(Handle& handle)
</span><span class="cx"> {
</span><span class="lines">@@ -162,7 +126,7 @@
</span><span class="cx"> {
</span><span class="cx">     return m_size;
</span><span class="cx"> }
</span><del>-    
</del><ins>+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(SHAREABLE_RESOURCE)
</span></span></pre></div>
<a id="trunkSourceWebKitSharedShareableResourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/ShareableResource.h (286407 => 286408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/ShareableResource.h   2021-12-02 02:10:30 UTC (rev 286407)
+++ trunk/Source/WebKit/Shared/ShareableResource.h      2021-12-02 02:12:37 UTC (rev 286408)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx">     
</span><del>-class ShareableResource : public RefCounted<ShareableResource> {
</del><ins>+class ShareableResource : public ThreadSafeRefCounted<ShareableResource> {
</ins><span class="cx"> public:
</span><span class="cx"> 
</span><span class="cx">     class Handle {
</span><span class="lines">@@ -84,8 +84,8 @@
</span><span class="cx"> 
</span><span class="cx">     Ref<SharedMemory> m_sharedMemory;
</span><span class="cx"> 
</span><del>-    unsigned m_offset;
-    unsigned m_size;    
</del><ins>+    const unsigned m_offset;
+    const unsigned m_size;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebCoreArgumentCoderscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (286407 => 286408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp     2021-12-02 02:10:30 UTC (rev 286407)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp        2021-12-02 02:12:37 UTC (rev 286408)
</span><span class="lines">@@ -234,7 +234,7 @@
</span><span class="cx">     if (sharedMemoryBuffer->size() < bufferSize)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), bufferSize);
</del><ins>+    buffer = sharedMemoryBuffer->createSharedBuffer(bufferSize);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     return true;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaWebPasteboardProxyCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm (286407 => 286408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm   2021-12-02 02:10:30 UTC (rev 286407)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm      2021-12-02 02:12:37 UTC (rev 286408)
</span><span class="lines">@@ -419,7 +419,7 @@
</span><span class="cx">         auto sharedMemoryBuffer = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly);
</span><span class="cx">         if (!sharedMemoryBuffer)
</span><span class="cx">             return completionHandler(0);
</span><del>-        auto buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), static_cast<size_t>(ipcHandle.dataSize));
</del><ins>+        auto buffer = sharedMemoryBuffer->createSharedBuffer(ipcHandle.dataSize);
</ins><span class="cx">         auto newChangeCount = PlatformPasteboard(pasteboardName).setBufferForType(buffer.ptr(), pasteboardType);
</span><span class="cx">         didModifyContentsOfPasteboard(connection, pasteboardName, previousChangeCount, newChangeCount);
</span><span class="cx">         completionHandler(newChangeCount);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (286407 => 286408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm     2021-12-02 02:10:30 UTC (rev 286407)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm        2021-12-02 02:12:37 UTC (rev 286408)
</span><span class="lines">@@ -588,7 +588,7 @@
</span><span class="cx">     if (!sharedMemoryBuffer)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), static_cast<size_t>(imageHandle.dataSize));
</del><ins>+    auto buffer = sharedMemoryBuffer->createSharedBuffer(imageHandle.dataSize);
</ins><span class="cx">     pageClient().saveImageToLibrary(WTFMove(buffer));
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessmacWebPageProxyMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (286407 => 286408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm     2021-12-02 02:10:30 UTC (rev 286407)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm        2021-12-02 02:12:37 UTC (rev 286408)
</span><span class="lines">@@ -240,7 +240,7 @@
</span><span class="cx">     auto sharedMemoryBuffer = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly);
</span><span class="cx">     if (!sharedMemoryBuffer)
</span><span class="cx">         return nullptr;
</span><del>-    return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), ipcHandle.dataSize);
</del><ins>+    return sharedMemoryBuffer->createSharedBuffer(ipcHandle.dataSize);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebPageProxy::readSelectionFromPasteboard(const String& pasteboardName)
</span><span class="lines">@@ -275,15 +275,14 @@
</span><span class="cx">     auto sharedMemoryImage = SharedMemory::map(imageHandle.handle, SharedMemory::Protection::ReadOnly);
</span><span class="cx">     if (!sharedMemoryImage)
</span><span class="cx">         return;
</span><ins>+    auto imageBuffer = sharedMemoryImage->createSharedBuffer(imageHandle.dataSize);
</ins><span class="cx"> 
</span><del>-    auto imageBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryImage->data()), static_cast<size_t>(imageHandle.dataSize));
</del><span class="cx">     RefPtr<SharedBuffer> archiveBuffer;
</span><del>-
</del><span class="cx">     if (!archiveHandle.handle.isNull()) {
</span><span class="cx">         auto sharedMemoryArchive = SharedMemory::map(archiveHandle.handle, SharedMemory::Protection::ReadOnly);
</span><span class="cx">         if (!sharedMemoryArchive)
</span><span class="cx">             return;
</span><del>-        archiveBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryArchive->data()), static_cast<size_t>(archiveHandle.dataSize));
</del><ins>+        archiveBuffer = sharedMemoryArchive->createSharedBuffer(archiveHandle.dataSize);
</ins><span class="cx">     }
</span><span class="cx">     pageClient().setPromisedDataForImage(pasteboardName, WTFMove(imageBuffer), ResourceResponseBase::sanitizeSuggestedFilename(filename), extension, title, url, visibleURL, WTFMove(archiveBuffer), originIdentifier);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebPlatformStrategiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (286407 => 286408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp  2021-12-02 02:10:30 UTC (rev 286407)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp     2021-12-02 02:12:37 UTC (rev 286408)
</span><span class="lines">@@ -145,7 +145,9 @@
</span><span class="cx">     if (ipcHandle.handle.isNull())
</span><span class="cx">         return nullptr;
</span><span class="cx">     RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly);
</span><del>-    return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), ipcHandle.dataSize);
</del><ins>+    if (!sharedMemoryBuffer)
+        return nullptr;
+    return sharedMemoryBuffer->createSharedBuffer(ipcHandle.dataSize);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPlatformStrategies::getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName, const PasteboardContext* context)
</span><span class="lines">@@ -412,7 +414,9 @@
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly);
</span><del>-    return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), ipcHandle.dataSize);
</del><ins>+    if (!sharedMemoryBuffer)
+        return nullptr;
+    return sharedMemoryBuffer->createSharedBuffer(ipcHandle.dataSize);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> URL WebPlatformStrategies::readURLFromPasteboard(size_t index, const String& pasteboardName, String& title, const PasteboardContext* context)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (286407 => 286408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2021-12-02 02:10:30 UTC (rev 286407)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2021-12-02 02:12:37 UTC (rev 286408)
</span><span class="lines">@@ -7738,7 +7738,7 @@
</span><span class="cx">         if (!sharedMemory)
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        document->appHighlightStorage().restoreAndScrollToAppHighlight(SharedBuffer::create(static_cast<const uint8_t*>(sharedMemory->data()), ipcHandle.dataSize), i == index ? ScrollToHighlight::Yes : ScrollToHighlight::No);
</del><ins>+        document->appHighlightStorage().restoreAndScrollToAppHighlight(sharedMemory->createSharedBuffer(ipcHandle.dataSize), i == index ? ScrollToHighlight::Yes : ScrollToHighlight::No);
</ins><span class="cx">         i++;
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>