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

Commit ed722378 authored by Andy Hung's avatar Andy Hung Committed by Android Build Cherrypicker Worker
Browse files

AudioPolicyManager: Fix memory leak

Refbase objects can leak the weakref_impl if created on the stack.
Fix deviceToAudioPort().

Test: see bug
Bug: 295257845
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:5b9a611ed53095a41e3e91b0cebf07701289b4c3)
Merged-In: I7d0363b4a1b725bdfa4949b85eb1a78c8b3d8ace
Change-Id: I7d0363b4a1b725bdfa4949b85eb1a78c8b3d8ace
parent c36f3abc
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -452,9 +452,9 @@ status_t AudioPolicyManager::setDeviceConnectionStateInt(const sp<DeviceDescript
status_t AudioPolicyManager::deviceToAudioPort(audio_devices_t device, const char* device_address,
                                               const char* device_name,
                                               media::AudioPortFw* aidlPort) {
    DeviceDescriptorBase devDescr(device, device_address);
    devDescr.setName(device_name);
    return devDescr.writeToParcelable(aidlPort);
    const auto devDescr = sp<DeviceDescriptorBase>::make(device, device_address);
    devDescr->setName(device_name);
    return devDescr->writeToParcelable(aidlPort);
}

void AudioPolicyManager::setEngineDeviceConnectionState(const sp<DeviceDescriptor> device,