Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 80136a1e authored by George Burgess IV's avatar George Burgess IV
Browse files

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
parent 7229576b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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_); }