libui: use uint64_t in dump and getTotalSize to avoid overflow issues
Fixes add-overflow errors caught by ubsan when running AHardwareBuffer
VK tests.
Test: dEQP-VK.api.external.memory.android_hardware_buffer.image_formats#r16g16b16a16_sfloat
Change-Id: I9ce1c9ee5f972a95a97de88a47d84982a99359c5
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index 1dd59f4..1c597f2 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -60,9 +60,9 @@
GraphicBufferAllocator::~GraphicBufferAllocator() {}
-size_t GraphicBufferAllocator::getTotalSize() const {
+uint64_t GraphicBufferAllocator::getTotalSize() const {
Mutex::Autolock _l(sLock);
- size_t total = 0;
+ uint64_t total = 0;
for (size_t i = 0; i < sAllocList.size(); ++i) {
total += sAllocList.valueAt(i).size;
}
@@ -72,7 +72,7 @@
void GraphicBufferAllocator::dump(std::string& result) const {
Mutex::Autolock _l(sLock);
KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);
- size_t total = 0;
+ uint64_t total = 0;
result.append("Allocated buffers:\n");
const size_t c = list.size();
for (size_t i=0 ; i<c ; i++) {