Skip to content

realArray: fix arrayCount tracking and assignment size safety#3

Open
spokening125 wants to merge 1 commit into
mohanchen:mainfrom
spokening125:main
Open

realArray: fix arrayCount tracking and assignment size safety#3
spokening125 wants to merge 1 commit into
mohanchen:mainfrom
spokening125:main

Conversation

@spokening125

Copy link
Copy Markdown

This PR improves safety and lifecycle tracking for realArray.

Changes

  • Decrement arrayCount when releasing memory.
  • Add assert(size == right.size) in copy assignment to prevent unsafe size-mismatched writes.

Impact

  • Keeps arrayCount accurate across object destruction.
  • Makes operator= safer in debug builds.
  • No API changes.

Copilot AI review requested due to automatic review settings March 30, 2026 15:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves ModuleBase::realArray safety and lifecycle tracking by ensuring the global arrayCount is decremented when memory is released and by preventing size-mismatched copy assignment writes (in debug builds).

Changes:

  • Decrement realArray::arrayCount inside realArray::freemem() (triggered by the destructor).
  • Add an assert(size == right.size) guard to realArray::operator=(const realArray&) to prevent unsafe copies when sizes differ.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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