| Summary: | Fix use-after-move in WebCore::SWClientConnection::postMessageToServiceWorkerClient() | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | David Kilzer (:ddkilzer) <ddkilzer> |
| Component: | Service Workers | Assignee: | youenn fablet <youennf> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | webkit-bug-importer, youennf |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Pull request: https://github.com/WebKit/WebKit/pull/7473 Committed 257728@main (34ebbe87e188): <https://commits.webkit.org/257728@main> Reviewed commits have been landed. Closing PR #7473 and removing active labels. |
Fix use-after-move in WebCore::SWClientConnection::postMessageToServiceWorkerClient() from Source/WebCore/workers/service/SWClientConnection.cpp. The `message` variable is involved in a use-after-move when `wasDispatched` returns `false` in the method below. ``` void SWClientConnection::postMessageToServiceWorkerClient(ScriptExecutionContextIdentifier destinationContextIdentifier, MessageWithMessagePorts&& message, ServiceWorkerData&& sourceData, String&& sourceOrigin) { ASSERT(isMainThread()); if (auto* destinationDocument = Document::allDocumentsMap().get(destinationContextIdentifier)) { postMessageToContainer(*destinationDocument, WTFMove(message), WTFMove(sourceData), WTFMove(sourceOrigin)); return; } bool wasDispatched = ScriptExecutionContext::postTaskTo(destinationContextIdentifier, [message = WTFMove(message), sourceData = WTFMove(sourceData).isolatedCopy(), sourceOrigin = WTFMove(sourceOrigin).isolatedCopy()](auto& context) mutable { postMessageToContainer(context, WTFMove(message), WTFMove(sourceData), WTFMove(sourceOrigin)); }); if (wasDispatched) return; if (auto* sharedWorker = SharedWorkerThreadProxy::byIdentifier(destinationContextIdentifier)) { sharedWorker->thread().runLoop().postTask([message = WTFMove(message), sourceData = WTFMove(sourceData).isolatedCopy(), sourceOrigin = WTFMove(sourceOrigin).isolatedCopy()] (auto& context) mutable { postMessageToContainer(context, WTFMove(message), WTFMove(sourceData), WTFMove(sourceOrigin)); }); } } ```