[PATCH] D70596: [analyzer][docs] NFC: Extend documentation for MallocOverflow checker
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 05:11:01 PST 2019
steakhal created this revision.
steakhal added reviewers: Szelethus, NoQ, krememek.
Herald added subscribers: cfe-commits, Charusso, donat.nagy, dexonsmith, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun, whisperity.
Herald added a project: clang.
Adds and example for `MallocOverflow` checker how to suppress the warning via checking the upper bound of the allocation size.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70596
Files:
clang/docs/analyzer/checkers.rst
Index: clang/docs/analyzer/checkers.rst
===================================================================
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -1974,6 +1974,12 @@
void *p = malloc(n * sizeof(int)); // warn
}
+ void test2(int n) {
+ if (n > 100) // gives an upper-bound
+ return;
+ void *p = malloc(n * sizeof(int)); // no warning
+ }
+
.. _alpha-security-MmapWriteExec:
alpha.security.MmapWriteExec (C)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70596.230635.patch
Type: text/x-patch
Size: 465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191122/a611e746/attachment.bin>
More information about the cfe-commits
mailing list