Tracks: Fix memory leak.
Test: compiles
Bug: 282476236
Bug: 281825210
Change-Id: Iceb776a259205ff414e843551156c908020cafa3
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 123d5a9..f6eac20 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -90,12 +90,13 @@
pid_t creatorPid,
uid_t clientUid,
bool isOut,
- alloc_type alloc,
+ const alloc_type alloc,
track_type type,
audio_port_handle_t portId,
std::string metricsId)
: RefBase(),
mThread(thread),
+ mAllocType(alloc),
mClient(client),
mCblk(NULL),
// mBuffer, mBufferSize
@@ -276,6 +277,10 @@
// relying on the automatic clear() at end of scope.
mClient.clear();
}
+ if (mAllocType == ALLOC_LOCAL) {
+ free(mBuffer);
+ mBuffer = nullptr;
+ }
// flush the binder command buffer
IPCThreadState::self()->flushCommands();
}