Bug 263615 - The URL move constructor doesn't invalidate the "moved-out" URL
Summary: The URL move constructor doesn't invalidate the "moved-out" URL
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-10-24 14:42 PDT by Chris Dumez
Modified: 2023-10-24 22:51 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2023-10-24 14:42:59 PDT
The URL move constructor doesn't invalidate the "moved-out" URL. This can lead WebKit code to do weird things.

For example, URLKeepingBlobAlive contains a m_url data member and is often moved-out to pass to a lambda. The destructor of the "moved-out" URLKeepingBlobAlive then runs and calls `unregisterBlobURLHandleIfNecessary()`. `unregisterBlobURLHandleIfNecessary()` will try to use m_url after it's been moved out to see if the URL protocol is "blob". This  causes URL::protocolIs() to try to do out-of-bound access in the underlying String (since the URL is marked as valid, even though it's m_string was moved out and other data members that are indexes into that string were not reset). Luckily, String's operator[] just returns nil when doing an out of bounds access at the moment.
Comment 1 Chris Dumez 2023-10-24 15:12:24 PDT
Pull request: https://github.com/WebKit/WebKit/pull/19512
Comment 2 EWS 2023-10-24 22:50:24 PDT
Committed 269750@main (e68882fc2467): <https://commits.webkit.org/269750@main>

Reviewed commits have been landed. Closing PR #19512 and removing active labels.
Comment 3 Radar WebKit Bug Importer 2023-10-24 22:51:15 PDT
<rdar://problem/117454783>