From c4142d91f5c549f7f3661aeb90d344641deabf62 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Mon, 22 Jun 2020 13:00:58 -0700 Subject: libafw: Use std::free explicitly for overlays Currently we rely on libc to call std::free on the malloced pointer to the overlay table entry. Rather than relying on the libc implementation to call std::free instead of trying to delete the pointer as if it was created using "new", explicitly pass std::free as the deleter to the data held by the std::shared_ptr. Bug: 159562360 Test: Observed no heap growth while looping infinitely and retrieving a string resource overlaid using an inline xml value Change-Id: I9a2ebaf9a993ad9c44fab8f052430c8142d4347d --- libs/androidfw/Idmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libs/androidfw/Idmap.cpp') diff --git a/libs/androidfw/Idmap.cpp b/libs/androidfw/Idmap.cpp index eb6ee9525bb9..5f231ffe4786 100644 --- a/libs/androidfw/Idmap.cpp +++ b/libs/androidfw/Idmap.cpp @@ -157,7 +157,7 @@ IdmapResMap::Result IdmapResMap::Lookup(uint32_t target_res_id) const { table_value->dataType = entry->type; table_value->data = entry->value; - return Result(ResTable_entry_handle::managed(table_entry)); + return Result(ResTable_entry_handle::managed(table_entry, [](auto p) { free(p); })); } static bool is_word_aligned(const void* data) { -- cgit v1.2.3-59-g8ed1b