[PATCH] D63720: [analyzer] ExprEngine: Escape pointers in bitwise operations
Csaba Dabis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 24 08:38:41 PDT 2019
Charusso created this revision.
Charusso added reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet.
After evaluation it would be an Unknown value and tracking would be lost.
Repository:
rC Clang
https://reviews.llvm.org/D63720
Files:
clang/test/Analysis/symbol-escape.cpp
Index: clang/test/Analysis/symbol-escape.cpp
===================================================================
--- /dev/null
+++ clang/test/Analysis/symbol-escape.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 \
+// RUN: -analyzer-checker=cplusplus.NewDeleteLeaks \
+// RUN: -verify %s
+
+#include <stdint.h>
+
+class C {};
+
+void payload(C *Foo) {
+ C *Bar = new C();
+ Bar = reinterpret_cast<C *>((reinterpret_cast<uintptr_t>(Foo) &
+ ~static_cast<uintptr_t>(0x1)) |
+ (reinterpret_cast<uintptr_t>(Bar) & 0x1));
+ (void)Bar;
+ // expected-warning at -1 {{Potential leak of memory pointed to by 'Bar'}}
+
+ delete Bar;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63720.206224.patch
Type: text/x-patch
Size: 691 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190624/6cd67d4a/attachment.bin>
More information about the cfe-commits
mailing list