aaudio: free endpoint to prevent crashes
Free the AudioEndpoint and check for nullptr to
prevent accessing shared memory that had been freed.
This is to protect against calls to the stream after
AAudioStream_release() has been called.
Bug: 154274446
Bug: 154274027
Test: libaaudio/tests/test_various.cpp
Change-Id: I194d502fd48c4d31602ffce76aca6b28753ad7d2
diff --git a/media/libaaudio/src/client/AudioEndpoint.h b/media/libaaudio/src/client/AudioEndpoint.h
index f5b67e8..484d917 100644
--- a/media/libaaudio/src/client/AudioEndpoint.h
+++ b/media/libaaudio/src/client/AudioEndpoint.h
@@ -35,7 +35,6 @@
public:
AudioEndpoint();
- virtual ~AudioEndpoint();
/**
* Configure based on the EndPointDescriptor_t.
@@ -67,11 +66,11 @@
*/
void setDataReadCounter(android::fifo_counter_t framesRead);
- android::fifo_counter_t getDataReadCounter();
+ android::fifo_counter_t getDataReadCounter() const;
void setDataWriteCounter(android::fifo_counter_t framesWritten);
- android::fifo_counter_t getDataWriteCounter();
+ android::fifo_counter_t getDataWriteCounter() const;
/**
* The result is not valid until after configure() is called.
@@ -94,8 +93,8 @@
void dump() const;
private:
- android::FifoBuffer *mUpCommandQueue;
- android::FifoBuffer *mDataQueue;
+ std::unique_ptr<android::FifoBuffer> mUpCommandQueue;
+ std::unique_ptr<android::FifoBuffer> mDataQueue;
bool mFreeRunning;
android::fifo_counter_t mDataReadCounter; // only used if free-running
android::fifo_counter_t mDataWriteCounter; // only used if free-running