diff options
author | Sungtak Lee <taklee@google.com> | 2019-04-16 02:50:18 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-04-16 02:50:18 -0700 |
commit | ae10c2b183bd46199d6db1bf617857b572afeda3 (patch) | |
tree | c43b95cddc5ef3dfd7bc5efa30c4c864fc16e530 | |
parent | c21acd54b09f196fb5699de0ef717f24a8397b94 (diff) | |
parent | e7e058d9b319d2784b9bbadcab93f6122f48fe0b (diff) | |
download | av-ae10c2b183bd46199d6db1bf617857b572afeda3.tar.gz |
Handle gralloc handle leaks
am: e7e058d9b3
Change-Id: I76a7b768024aba691612a58d73be6fca1ceca4f7
-rw-r--r-- | codec2/vndk/C2AllocatorGralloc.cpp | 5 | ||||
-rw-r--r-- | media/sfplugin/C2OMXNode.cpp | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/codec2/vndk/C2AllocatorGralloc.cpp b/codec2/vndk/C2AllocatorGralloc.cpp index 63df23f..c80e6f8 100644 --- a/codec2/vndk/C2AllocatorGralloc.cpp +++ b/codec2/vndk/C2AllocatorGralloc.cpp @@ -316,6 +316,11 @@ C2AllocationGralloc::~C2AllocationGralloc() { native_handle_delete( const_cast<native_handle_t *>(reinterpret_cast<const native_handle_t *>(mHandle))); } + if (mLockedHandle) { + native_handle_delete( + const_cast<native_handle_t *>( + reinterpret_cast<const native_handle_t *>(mLockedHandle))); + } } c2_status_t C2AllocationGralloc::map( diff --git a/media/sfplugin/C2OMXNode.cpp b/media/sfplugin/C2OMXNode.cpp index 749fd7a..9500aed 100644 --- a/media/sfplugin/C2OMXNode.cpp +++ b/media/sfplugin/C2OMXNode.cpp @@ -225,14 +225,18 @@ status_t C2OMXNode::emptyBuffer( if (omxBuf.mBufferType == OMXBuffer::kBufferTypeANWBuffer && omxBuf.mGraphicBuffer != nullptr) { std::shared_ptr<C2GraphicAllocation> alloc; + native_handle_t *clonedHandle = native_handle_clone(omxBuf.mGraphicBuffer->handle); handle = WrapNativeCodec2GrallocHandle( - native_handle_clone(omxBuf.mGraphicBuffer->handle), + clonedHandle, omxBuf.mGraphicBuffer->width, omxBuf.mGraphicBuffer->height, omxBuf.mGraphicBuffer->format, omxBuf.mGraphicBuffer->usage, omxBuf.mGraphicBuffer->stride); c2_status_t err = mAllocator->priorGraphicAllocation(handle, &alloc); + if (clonedHandle) { + native_handle_delete(clonedHandle); + } if (err != OK) { return UNKNOWN_ERROR; } |