summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Xiao Zhang <zhangxiao19@xiaomi.corp-partner.google.com> 2024-11-29 09:08:16 +0000
committer Xiao Zhang <zhangxiao19@xiaomi.corp-partner.google.com> 2024-12-02 01:38:06 +0000
commit23349ea383c162a1185f94ea64ff66aad15109a7 (patch)
treea4b398cabe1b6e596d586ca799f65303056a20e6
parentbd28005fead6cea70a6213d37071ee7313f1839f (diff)
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
-rw-r--r--libs/ui/GraphicBuffer.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index b0c6e44b2b..18c9a6bc48 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -596,6 +596,8 @@ status_t GraphicBuffer::unflatten(void const*& buffer, size_t& size, int const*&
width = height = stride = format = usage_deprecated = 0;
layerCount = 0;
usage = 0;
+ native_handle_close(handle);
+ native_handle_delete(const_cast<native_handle_t*>(handle));
handle = nullptr;
ALOGE("unflatten: registerBuffer failed: %s (%d)", strerror(-err), err);
return err;