From 1aa40037fde7e57ae99468b9dd40e7788ed3978b Mon Sep 17 00:00:00 2001 From: Pavlin Radoslavov Date: Thu, 2 Feb 2017 19:47:16 -0800 Subject: [PATCH] Fix a memory leak in the osi allocation tracker Add a missing free(allocation) inside allocation_tracker_notify_free() when freeing a memory buffer. Prior to switching the allocation tracker to use C++ unordered_map, the "allocation" bin was kept within (and reused) by the older hash_map mechanism. However, after the switch to the C++ unordered_map this is no longer the case, hence the memory leak. Test: watch -n 1 "adb shell dumpsys meminfo -d BT-PID | grep Heap" Bug: 34785845 Change-Id: I737c901a6452d29d18fd8b847e7d5ea10c5ff485 --- osi/src/allocation_tracker.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/osi/src/allocation_tracker.cc b/osi/src/allocation_tracker.cc index 461e34283..2dee1dc47 100644 --- a/osi/src/allocation_tracker.cc +++ b/osi/src/allocation_tracker.cc @@ -165,6 +165,7 @@ void* allocation_tracker_notify_free(UNUSED_ATTR uint8_t allocator_id, // Double-free of memory is detected with "assert(allocation)" above // as the allocation entry will not be present. allocations.erase(ptr); + free(allocation); return ((char*)ptr) - canary_size; } -- 2.11.0