Skip to content

Commit ab3a3ac

Browse files
committed
Fix memory corruption when swapping URIs
Simply swapping the string_view is not valid as std::basic_string::swap might invalidate existing iterators and pointers. I couldn't find a minimal test to reproduce it because it's unclear when iterators are invalidated.
1 parent 69a272b commit ab3a3ac

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/uri.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ uri &uri::operator=(uri other) {
195195

196196
void uri::swap(uri &other) noexcept {
197197
uri_.swap(other.uri_);
198-
uri_view_.swap(other.uri_view_);
198+
uri_view_ = uri_;
199+
other.uri_view_ = other.uri_;
199200

200201
const auto this_parts = uri_parts_;
201202
detail::advance_parts(uri_view_, uri_parts_, other.uri_parts_);

0 commit comments

Comments
 (0)