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

Commit 7045fa1c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "topshim: a2dp: Avoid leaking the reference of a stack object" into main

parents 231e391f b15a0751
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -239,18 +239,15 @@ static ::rust::Vec<A2dpCodecConfig> to_rust_codec_config_vec(
  return rconfigs;
}

static A2dpError to_rust_error(const btav_error_t& error) {
static void connection_state_cb(const RawAddress& addr, btav_connection_state_t state,
                                const btav_error_t& error) {
  // CAUTION: The error_msg field is a reference and could refer to a rvalue on the stack.
  //          DO NOT make this conversion into a helper function.
  A2dpError a2dp_error = {
          .status = error.status,
          .error_code = error.error_code,
          .error_msg = error.error_msg.value_or(""),
  };
  return a2dp_error;
}

static void connection_state_cb(const RawAddress& addr, btav_connection_state_t state,
                                const btav_error_t& error) {
  A2dpError a2dp_error = to_rust_error(error);
  rusty::connection_state_callback(addr, state, a2dp_error);
}
static void audio_state_cb(const RawAddress& addr, btav_audio_state_t state) {
+4 −7
Original line number Diff line number Diff line
@@ -32,18 +32,15 @@ namespace rust {
namespace internal {
static A2dpSinkIntf* g_a2dp_sink_if;

static A2dpError to_rust_error(const btav_error_t& error) {
static void connection_state_cb(const RawAddress& addr, btav_connection_state_t state,
                                const btav_error_t& error) {
  // CAUTION: The error_msg field is a reference and could refer to a rvalue on the stack.
  //          DO NOT make this conversion into a helper function.
  A2dpError a2dp_error = {
          .status = error.status,
          .error_code = error.error_code,
          .error_msg = error.error_msg.value_or(""),
  };
  return a2dp_error;
}

static void connection_state_cb(const RawAddress& addr, btav_connection_state_t state,
                                const btav_error_t& error) {
  A2dpError a2dp_error = to_rust_error(error);
  rusty::sink_connection_state_callback(addr, state, a2dp_error);
}
static void audio_state_cb(const RawAddress& addr, btav_audio_state_t state) {