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

Commit 0d7fb838 authored by Jack He's avatar Jack He
Browse files

HFP: Do not use data in bta_ag_start_open if data is empty

* bta_ag_start_open() should not use data when data is empty

Change-Id: Id16d8c0ca90cbecb1b54900bd7f37a6c5c467ebd
Fixes: 72164296
Bug: 72164296
Test: make, pair and connect Bluetooth devices
parent 21977800
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -176,9 +176,11 @@ void bta_ag_start_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
  RawAddress pending_bd_addr = {};

  /* store parameters */
  if (!data.IsEmpty()) {
    p_scb->peer_addr = data.api_open.bd_addr;
    p_scb->open_services = data.api_open.services;
    p_scb->cli_sec_mask = data.api_open.sec_mask;
  }

  /* Check if RFCOMM has any incoming connection to avoid collision. */
  if (PORT_IsOpening(pending_bd_addr)) {
+17 −0
Original line number Diff line number Diff line
@@ -164,6 +164,23 @@ union tBTA_AG_DATA {
  tBTA_AG_DISC_RESULT disc_result;
  tBTA_AG_RFC rfc;
  static const tBTA_AG_DATA kEmpty;

  /**
   * Check if two tBTA_AG_DATA are equal in memory
   *
   * @param rhs other tBTA_AG_DATA
   * @return true if both unions are equal in memory
   */
  bool operator==(const tBTA_AG_DATA& rhs) const {
    return (std::memcmp(this, &rhs, sizeof(tBTA_AG_DATA)) == 0);
  }

  /**
   * Check if this union is empty by comparing it to the kEmpty constant
   *
   * @return true if this union is empty
   */
  bool IsEmpty() const { return *this == kEmpty; }
};

/* type for each profile */