libutil: reject borrowing URL accessors on temporaries - #16337
Open
domenkozar wants to merge 1 commit into
Open
Conversation
xokdvium
reviewed
Aug 20, 2026
xokdvium
reviewed
Aug 20, 2026
`VerbatimURL::scheme()` and `ParsedURL::pathSegments()` return non-owning views into the object they are called on. Their `const &` qualifiers also bind to rvalues, so a temporary URL can hand out a view that dangles as soon as the enclosing full expression ends. Add deleted rvalue-qualified overloads so those calls are rejected at compile time. This also rejects rvalue uses that are safe today, such as collecting the segments into a container within the same full expression, so the path-segment test now names the URL it borrows from. Assisted-by: Claude Code (Claude Opus 5) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
domenkozar
force-pushed
the
local-pr/url-accessor-lifetime-dcb494e63
branch
from
August 21, 2026 00:01
0ed57cc to
79a7d59
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
VerbatimURL::scheme()andParsedURL::pathSegments()return non-owning views into the object they are called on. However, theirconst &qualifiers still allow calls on rvalues. If a returned view is retained past the end of that full expression, it refers to an already-destroyed URL.Add deleted
const &&overloads so these unsafe calls are rejected at compile time. Callers must keep the owning URL alive; update the path-segment test accordingly.Assisted-by: Claude Code (Claude Opus 5)
Motivation
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.