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

Commit db76ab3f authored by Aritra Sen's avatar Aritra Sen
Browse files

Replace constructs with an if check to avoid crashes when nullptr happens

Bug: 285791484
Test: N/A
Tag: #refractor
Change-Id: I0e19576644e9b471fdcf31f0b2ff9c7c0ee4c8dd
parent 5c2ae263
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -792,7 +792,10 @@ bool BtaAvCo::IsSupportedCodec(btav_a2dp_codec_index_t codec_index) {
  // All peer state is initialized with the same local codec config,
  // hence we check only the first peer.
  A2dpCodecs* codecs = peers_[0].GetCodecs();
  CHECK(codecs != nullptr);
  if (codecs == nullptr) {
    LOG_ERROR("Peer codecs is set to null");
    return false;
  }
  return codecs->isSupportedCodec(codec_index);
}

@@ -1700,7 +1703,10 @@ bool BtaAvCo::ReportSourceCodecState(BtaAvCoPeer* p_peer) {
  VLOG(1) << __func__ << ": peer_address="
          << ADDRESS_TO_LOGGABLE_STR(p_peer->addr);
  A2dpCodecs* codecs = p_peer->GetCodecs();
  CHECK(codecs != nullptr);
  if (codecs == nullptr) {
    LOG_ERROR("Peer codecs is set to null");
    return false;
  }
  if (!codecs->getCodecConfigAndCapabilities(&codec_config,
                                             &codecs_local_capabilities,
                                             &codecs_selectable_capabilities)) {