Skip to content

fix: add bounds safety net in graphical_select to prevent undefined behavior#3047

Closed
Shubham-py404 wants to merge 1 commit intoMoganLab:mainfrom
Shubham-py404:fix-ellipse-array-bounds
Closed

fix: add bounds safety net in graphical_select to prevent undefined behavior#3047
Shubham-py404 wants to merge 1 commit intoMoganLab:mainfrom
Shubham-py404:fix-ellipse-array-bounds

Conversation

@Shubham-py404
Copy link
Copy Markdown

This PR resolves the array out-of-bounds issue when interacting with ellipses using the selection tools.

As discussed by @GatsbyUSTC in the previously closed PR (#2948), hardcoding the array initialization to 3 is a temporary workaround. Instead, this PR implements a permanent safety net inside curve_box_rep::graphical_select in graphics_boxes.cpp.

Before the array indices are calculated, the code now checks if np exceeds the actual size of the abs array using N(abs). If it does, it truncates np to prevent the loop from accessing unallocated memory, fully eliminating the undefined behavior and the resulting infinite loop/crash.

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