Skip to content

C++: Add use-after-free FP tests#19397

Merged
jketema merged 1 commit intogithub:mainfrom
jketema:use-after-free
Apr 29, 2025
Merged

C++: Add use-after-free FP tests#19397
jketema merged 1 commit intogithub:mainfrom
jketema:use-after-free

Conversation

@jketema
Copy link
Copy Markdown
Contributor

@jketema jketema commented Apr 28, 2025

These derive from #19387. Note that these FPs are a known issue.

@github-actions github-actions Bot added the C++ label Apr 28, 2025
@jketema jketema marked this pull request as ready for review April 28, 2025 12:42
Copilot AI review requested due to automatic review settings April 28, 2025 12:42
@jketema jketema requested a review from a team as a code owner April 28, 2025 12:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds tests for known false positives related to use-after-free issues in C++ code.

  • Removed an unused pointer variable in test9.
  • Introduced new structures and a function (malloc_after_free) to simulate use-after-free scenarios consistent with reported false positives.
Files not reviewed (1)
  • cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/UseAfterFree/UseAfterFree.expected: Language not supported

return;
}
use(s->i1.data); // GOOD [FALSE POSITIVE]

Copy link

Copilot AI Apr 28, 2025

Choose a reason for hiding this comment

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

s->i2 is dereferenced without a prior check for null, which could lead to a segmentation fault if s->i2 is not properly initialized. Consider adding a null check for s->i2 before dereferencing.

Suggested change
if (s->i2 == NULL) {
return;
}

Copilot uses AI. Check for mistakes.
@jketema jketema merged commit 966b746 into github:main Apr 29, 2025
9 checks passed
@jketema jketema deleted the use-after-free branch April 29, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants