diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2015-12-19 07:56:25 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-12-19 07:56:25 -0800 |
commit | a5aefe9e3ab119b305538a09bde05b94dfda96f3 (patch) | |
tree | db9bf8c8ce84a0cd2745a0a27eb0edd79ba63b05 | |
parent | a69b205e21329391537fbefd4994fa8549f5eca4 (diff) | |
parent | 14e47ee87a4ebd6cfe0292971c4938057383e18c (diff) | |
download | android_system_bt-a5aefe9e3ab119b305538a09bde05b94dfda96f3.tar.gz android_system_bt-a5aefe9e3ab119b305538a09bde05b94dfda96f3.tar.bz2 android_system_bt-a5aefe9e3ab119b305538a09bde05b94dfda96f3.zip |
Merge "Bluetooth: Free hash map entry to avoid memory leak" into LA.BF.1.1.3_rb1.6
-rw-r--r-- | osi/include/allocation_tracker.h | 2 | ||||
-rw-r--r-- | osi/src/allocation_tracker.c | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/osi/include/allocation_tracker.h b/osi/include/allocation_tracker.h index b9fa59405..d4934dbe0 100644 --- a/osi/include/allocation_tracker.h +++ b/osi/include/allocation_tracker.h @@ -22,6 +22,8 @@ #include <stddef.h> #include <stdint.h> +#define OSI_ALLOC_TRACK_DOUBLE_FREE FALSE + typedef struct allocation_tracker_t allocation_tracker_t; typedef uint8_t allocator_id_t; diff --git a/osi/src/allocation_tracker.c b/osi/src/allocation_tracker.c index 0124b68c3..2ef3983aa 100644 --- a/osi/src/allocation_tracker.c +++ b/osi/src/allocation_tracker.c @@ -170,6 +170,13 @@ void *allocation_tracker_notify_free(uint8_t allocator_id, void *ptr) { assert(end_canary[i] == canary[i]); } + // free hash map entry to avoid memory leak on long run. + // double free detected with above assert(allocation) + // as the allocation entry will not present. +#if (defined(OSI_ALLOC_TRACK_DOUBLE_FREE) && (OSI_ALLOC_TRACK_DOUBLE_FREE == FALSE)) + hash_map_erase(allocations, ptr); +#endif + pthread_mutex_unlock(&lock); return ((char *)ptr) - canary_size; |