From 1079406cab09090cc11e26d4ac2f1ba9c4930cdb Mon Sep 17 00:00:00 2001 From: Dmitriy Ivanov Date: Wed, 14 May 2014 12:52:57 -0700 Subject: [PATCH] Fix for linker allocator Change-Id: I18a3f1a8515657f0deb69266184fb516a27f90e8 --- linker/linker_allocator.cpp | 2 +- linker/tests/linker_allocator_test.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/linker/linker_allocator.cpp b/linker/linker_allocator.cpp index 60ce1ea47..573809075 100644 --- a/linker/linker_allocator.cpp +++ b/linker/linker_allocator.cpp @@ -117,8 +117,8 @@ LinkerAllocatorPage* LinkerBlockAllocator::find_page(void* block) { } LinkerAllocatorPage* page = page_list_; - const uint8_t* page_ptr = reinterpret_cast(page); while (page != nullptr) { + const uint8_t* page_ptr = reinterpret_cast(page); if (block >= (page_ptr + sizeof(page->next)) && block < (page_ptr + PAGE_SIZE)) { return page; } diff --git a/linker/tests/linker_allocator_test.cpp b/linker/tests/linker_allocator_test.cpp index e3a91c59f..0ed82528f 100644 --- a/linker/tests/linker_allocator_test.cpp +++ b/linker/tests/linker_allocator_test.cpp @@ -96,6 +96,9 @@ TEST(linker_allocator, test_larger) { ASSERT_TRUE(allocator.alloc() != nullptr); } + test_struct_larger* ptr_to_free = allocator.alloc(); + ASSERT_TRUE(ptr_to_free != nullptr); + allocator.free(ptr1); } static void protect_all() {