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

Commit 7bfb6c13 authored by George Burgess IV's avatar George Burgess IV
Browse files

reactor: guard against a potential segfault

If this `if/else if` falls through, we'll dereference event.data.ptr
below.

Caught by the static analyzer:
system/bt/gd/os/linux_generic/reactor.cc:131:37: warning: Forming
reference to null pointer [clang-analyzer-core.NonNullParamChecker]

Bug: None
Test: TreeHugger
Change-Id: I5800ec3772db118ae6c75b40c638fea480248db6
parent 8e8077ff
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <algorithm>
#include <cerrno>
#include <cinttypes>
#include <cstring>

#include "os/log.h"
@@ -117,6 +118,9 @@ void Reactor::Run() {
          timeout_ms = 30;
          waiting_for_idle = true;
          continue;
        } else {
          LOG_ERROR("Unknown control_fd value %" PRIu64 "x", value);
          continue;
        }
      }
      auto* reactable = static_cast<Reactor::Reactable*>(event.data.ptr);