Skip to content

Commit 23349ea

Browse files
author
Xiao Zhang
committed
fix potential leakage issues
If validating the size of the buffer fails during the flattening process of GraphicBuffer, fd leakage will occur; You can easily reproduce this problem when validating the size of the buffer fails or simply setting the error to non NOERROR. Bug: 381504577 Test: Manual Change-Id: I7e0ba4a889d6888cc5794a0f226f6638e104eb81
1 parent bd28005 commit 23349ea

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

libs/ui/GraphicBuffer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ status_t GraphicBuffer::unflatten(void const*& buffer, size_t& size, int const*&
596596
width = height = stride = format = usage_deprecated = 0;
597597
layerCount = 0;
598598
usage = 0;
599+
native_handle_close(handle);
600+
native_handle_delete(const_cast<native_handle_t*>(handle));
599601
handle = nullptr;
600602
ALOGE("unflatten: registerBuffer failed: %s (%d)", strerror(-err), err);
601603
return err;

0 commit comments

Comments
 (0)