Skip to content

I Fixed copy_array dangling pointer bug in VPolytope#473

Open
DhanushShetty18 wants to merge 1 commit into
GeomScale:developfrom
DhanushShetty18:fix/vpolytope-copy-array-dangling-pointer
Open

I Fixed copy_array dangling pointer bug in VPolytope#473
DhanushShetty18 wants to merge 1 commit into
GeomScale:developfrom
DhanushShetty18:fix/vpolytope-copy-array-dangling-pointer

Conversation

@DhanushShetty18

@DhanushShetty18 DhanushShetty18 commented Mar 12, 2026

Copy link
Copy Markdown

Hello , Myself Dhanush (Artificial Intelligence and Data Science Student)
While exploring the VPolytope implementation for GSoC 2026,
I noticed a TODO comment on line 30 about raw pointer usage.
then found that copy_array() takes T* result
by value. The result = tarray inside the function
only updates a local copy , the caller's pointer remains pointing
to freed memory (dangling pointer), and the newly allocated
memory is leaked.

Fix:
1.Changed return type from void to T* and return the newly allocated array..
2.Updated all 6 call sites in operator= to capture the returned pointer.
THEN,
Added a test in volume_cb_vpolytope.cpp that copies a
VPolytope and verifies the copy is usable after assignment and
tested with full_dimensional_polytope_test:
9 tests, 38 assertions, 0 failures.

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.

1 participant