Skip to content

Fix 14934: detect out-of-bounds access to global new arrays - #8828

Open
JeewoongKim wants to merge 1 commit into
cppcheck-opensource:mainfrom
JeewoongKim:fix-14934-global-buffer-size
Open

Fix 14934: detect out-of-bounds access to global new arrays#8828
JeewoongKim wants to merge 1 commit into
cppcheck-opensource:mainfrom
JeewoongKim:fix-14934-global-buffer-size

Conversation

@JeewoongKim

Copy link
Copy Markdown

Global pointers initialized with new[] did not get a BUFFER_SIZE value because
valueFlowDynamicBufferSize() only handled allocations found inside function scopes.

This change propagates the initial buffer size into main(). The existing value-flow analysis
invalidate it after assignments or calls that may modify the global pointer.

Added regression tests for the reported out-of-bounds false negative, reassignment of the
global pointer, and an unknown function call that may modify it.

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