summaryrefslogtreecommitdiffstats
path: root/libmemunreachable
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2017-09-24 13:36:29 -0700
committerGeorge Burgess IV <gbiv@google.com>2017-09-24 13:36:29 -0700
commit80136a1e4142d66846cf9024ac83346a9444cdca (patch)
treee090abd375b3570d59ea39f96d38626831e697d2 /libmemunreachable
parent7229576bfed017f78d90102db357de2f9f1f5b45 (diff)
downloadsystem_core-80136a1e4142d66846cf9024ac83346a9444cdca.tar.gz
system_core-80136a1e4142d66846cf9024ac83346a9444cdca.tar.bz2
system_core-80136a1e4142d66846cf9024ac83346a9444cdca.zip
Silence static analyzer warnings about memory leaks
The static analyzer complains that this memory is leaked regardless of how I try to work around it (unless we escape the memory by using a global or something, but...). Basically, as long as there's some sort of operation on the reinterpret_cast'ed pointer, it complains. If we remove the bitwise negations, it doesn't. Doing so would presumably defeat the purpose of this test, though, so add a NOLINT. Bug: 27101951 Test: mma. No more static analyzer warning for this file. Change-Id: If9008946a2145d17b8651535141bfd7ec9224739
Diffstat (limited to 'libmemunreachable')
-rw-r--r--libmemunreachable/tests/MemUnreachable_test.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/libmemunreachable/tests/MemUnreachable_test.cpp b/libmemunreachable/tests/MemUnreachable_test.cpp
index ec8938885..87417f132 100644
--- a/libmemunreachable/tests/MemUnreachable_test.cpp
+++ b/libmemunreachable/tests/MemUnreachable_test.cpp
@@ -27,6 +27,9 @@ namespace android {
class HiddenPointer {
public:
+ // Since we're doing such a good job of hiding it, the static analyzer
+ // thinks that we're leaking this `malloc`. This is probably related to
+ // https://bugs.llvm.org/show_bug.cgi?id=34198. NOLINTNEXTLINE
explicit HiddenPointer(size_t size = 256) { Set(malloc(size)); }
~HiddenPointer() { Free(); }
void* Get() { return reinterpret_cast<void*>(~ptr_); }