Skip to content

Close open submessage when move-assigning onto a writer - #167

Merged
joto merged 1 commit into
masterfrom
kk/fix-writer-move-assignment
Nov 2, 2026
Merged

joto merged 1 commit into
masterfrom
kk/fix-writer-move-assignment

Conversation

@kkaefer

@kkaefer kkaefer commented Nov 2, 2026

Copy link
Copy Markdown
Member

Move-assigning onto a basic_pbf_writer for an open submessage overwrote it without closing the submessage, leaving the parent stuck with an open submessage. Self-move-assignment also invalidated the writer.

The fix is to simply use a move-and-swap so the old state is closed by the temporary object's destructor, the same way it is when a writer goes out of scope.

Move-assigning onto a basic_pbf_writer for an open submessage overwrote
it without closing the submessage, leaving the parent stuck with an
open submessage. Self-move-assignment also invalidated the writer.

Use move-and-swap so the old state is closed by the temporary's
destructor, the same way it is when a writer goes out of scope.
@kkaefer
kkaefer requested a review from a team as a code owner November 2, 2026 14:49
@kkaefer
kkaefer requested a review from joto November 2, 2026 14:49
@joto
joto merged commit c6ea615 into master Nov 2, 2026
72 checks passed
@kkaefer
kkaefer deleted the kk/fix-writer-move-assignment branch November 3, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants