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

Commit 4381ebe3 authored by Jakub Rotkiewicz's avatar Jakub Rotkiewicz
Browse files

aidl/provider_info: fix possible memory leak

Bug: 305734815
Test: m com.android.btservices

Change-Id: I9f9b8bead028ccc59824428f86f0e7361d0cc9a5
parent c5170404
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ BluetoothAudioSinkClientInterface* active_hal_interface = nullptr;
// ProviderInfo for A2DP hardware offload encoding and decoding data paths,
// if supported by the HAL and enabled. nullptr if not supported
// or disabled.
::bluetooth::audio::aidl::a2dp::ProviderInfo* provider_info;
std::unique_ptr<::bluetooth::audio::aidl::a2dp::ProviderInfo> provider_info;

// Save the value if the remote reports its delay before this interface is
// initialized
+3 −2
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ using ::aidl::android::hardware::bluetooth::audio::SessionType;
 * getProviderInfo, or if the feature flag for codec
 * extensibility is disabled.
 ***/
ProviderInfo* ProviderInfo::GetProviderInfo() {
std::unique_ptr<ProviderInfo> ProviderInfo::GetProviderInfo() {
  if (!IS_FLAG_ENABLED(a2dp_offload_codec_extensibility)) {
    LOG(INFO) << "a2dp offload codec extensibility is disabled;"
              << " not going to load the ProviderInfo";
@@ -78,7 +78,8 @@ ProviderInfo* ProviderInfo::GetProviderInfo() {
    sink_codecs = std::move(sink_provider_info->codecInfos);
  }

  return new ProviderInfo(std::move(source_codecs), std::move(sink_codecs));
  return std::make_unique<ProviderInfo>(std::move(source_codecs),
                                        std::move(sink_codecs));
}

/***
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ class ProviderInfo {
   * getProviderInfo, or if the feature flag for codec
   * extensibility is disabled.
   ***/
  static ProviderInfo* GetProviderInfo();
  static std::unique_ptr<ProviderInfo> GetProviderInfo();

  ProviderInfo(std::vector<CodecInfo> source_codecs,
               std::vector<CodecInfo> sink_codecs);