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

Commit 10ffd1ec authored by Chienyuan Huang's avatar Chienyuan Huang
Browse files

RAS: Prevent null pointer dereference while the service is not found

Flag: com.android.bluetooth.flags.channel_sounding_in_stack
Bug: 324185011
Bug: 382732414
Test: m com.android.btservice
Change-Id: Iba835cd682cc44f223111eca5ba678edb5ac16fa
parent 28ef7557
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -110,6 +110,10 @@ public:
    uint16_t conn_interval_ = kInvalidConnInterval;

    const gatt::Characteristic* FindCharacteristicByUuid(Uuid uuid) {
      if (service_ == nullptr) {
        log::error("Can't find Ranging Service");
        return nullptr;
      }
      for (auto& characteristic : service_->characteristics) {
        if (characteristic.uuid == uuid) {
          return &characteristic;
@@ -117,6 +121,7 @@ public:
      }
      return nullptr;
    }

    const gatt::Characteristic* FindCharacteristicByHandle(uint16_t handle) {
      for (auto& characteristic : service_->characteristics) {
        if (characteristic.value_handle == handle) {