Skip to content

fix: return owned values from generated pop_back - #831

Draft
tomatotomata wants to merge 1 commit into
bytedeco:masterfrom
tomatotomata:codex/safe-vector-pop-back-830
Draft

fix: return owned values from generated pop_back#831
tomatotomata wants to merge 1 commit into
bytedeco:masterfrom
tomatotomata:codex/safe-vector-pop-back-830

Conversation

@tomatotomata

Copy link
Copy Markdown

Fixes the dangling-reference path reported in #830.

The generated pop_back() implementation now reads the final element through a separate @ByVal operator[] binding before resizing the container. That makes the returned JavaCPP wrapper own a copy of the value instead of aliasing the element that resize() destroys. The existing get() binding remains by-reference for normal indexed access.

I kept this scoped to resizable, long-indexed containers such as std::vector and std::deque, which are the containers that currently receive the generated pop_back() helper.

Validation:

  • git diff --check
  • Full Maven tests were not available because this environment has no Maven installation.

Related: #830

Signed-off-by: ahmadalguydi <ahmadalgaidy@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants