Skip to content

[-Wunsafe-buffer-usage] Warning for unsafe invocation of span::data (… #7965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

malavikasamak
Copy link

llvm#75650)

…-Wunsafe-buffer-usage,

there maybe accidental re-introduction of new OutOfBound accesses into the code bases. One such case is invoking span::data() method on a span variable to retrieve a pointer, which is then cast to a larger type and dereferenced. Such dereferences can introduce OutOfBound accesses.

To address this, a new WarningGadget is being introduced to warn against such invocations.


Co-authored-by: MalavikaSamak [email protected]
(cherry picked from commit 7122f55)

…lvm#75650)

…-Wunsafe-buffer-usage,

there maybe accidental re-introduction of new OutOfBound accesses into
the code bases. One such case is invoking span::data() method on a span
variable to retrieve a pointer, which is then cast to a larger type and
dereferenced. Such dereferences can introduce OutOfBound accesses.

To address this, a new WarningGadget is being introduced to warn against
such invocations.

---------

Co-authored-by: MalavikaSamak <[email protected]>
(cherry picked from commit 7122f55)
@malavikasamak
Copy link
Author

@swift-ci test

@malavikasamak malavikasamak merged commit fa6a1d9 into swiftlang:stable/20230725 Jan 12, 2024
@malavikasamak malavikasamak deleted the static-analyzer-wunsafe-buffer-data-invocation-cherrypick branch July 22, 2024 20:19
@malavikasamak malavikasamak restored the static-analyzer-wunsafe-buffer-data-invocation-cherrypick branch July 22, 2024 20:19
@malavikasamak malavikasamak deleted the static-analyzer-wunsafe-buffer-data-invocation-cherrypick branch July 22, 2024 20:46
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