Skip to content

Fix memory leak in Array move assignment - #981

Merged
bbuchfink merged 1 commit into
bbuchfink:masterfrom
kevinmoran1988:pr/array-move-leak
Sep 21, 2026
Merged

bbuchfink merged 1 commit into
bbuchfink:masterfrom
kevinmoran1988:pr/array-move-leak

Conversation

@kevinmoran1988

Copy link
Copy Markdown
Contributor

Array::operator=(Array&&) overwrote ptr_ without freeing the buffer it already
owned, so every move assignment into a non-empty Array leaked. This frees the
current buffer first and guards against self-assignment, so a = std::move(a)
does not free the buffer it is about to keep.

Builds on v2.2.8 (745cd3b) and passes ctest.

An AI assistant (Claude Code Opus 5.0) assisted with this work.

Array::operator=(Array&&) overwrote ptr_ without freeing the buffer it
already owned. Free the current buffer first and guard against
self-assignment.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@bbuchfink bbuchfink left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@bbuchfink
bbuchfink merged commit 5e25aca into bbuchfink:master Sep 21, 2026
@kevinmoran1988
kevinmoran1988 deleted the pr/array-move-leak branch September 21, 2026 17: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