From 23b851d8f39e9ed2e617e181911f01ac54290367 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 27 Jun 2024 14:00:39 +0900 Subject: [PATCH] Version 2.4, fixes Fix free not actually calling real_free. Fix free dereferencing null ptr. TODO fix bug where tracked data is not correctly removed during free. --- CMakeLists.txt | 2 +- Changelog.md | 6 ++++++ src/another_memcheck.cc | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e46be10..e71030a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.7) project(AnotherMemCheck) -set(AnotherMemCheck_VERSION 2.2) +set(AnotherMemCheck_VERSION 2.4) set(AnotherMemCheck_SOVERSION 2) set(AnotherMemCheck_SOURCES diff --git a/Changelog.md b/Changelog.md index 99aa516..65b26a5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,11 @@ # Changelog +## Version 2.4 + +Fixed free() not actually calling real_free(). + +Fixed nullptr dereference during free. + ## Version 2.3 Added ids to each chunk of allocated memory to make it easier to keep track of diff --git a/src/another_memcheck.cc b/src/another_memcheck.cc index 448141b..9c9a7a4 100644 --- a/src/another_memcheck.cc +++ b/src/another_memcheck.cc @@ -43,7 +43,7 @@ namespace SC_AM_Internal { ListNode *node = head; while (node != nullptr) { node = node->next; - if (node->data && node->data->address == ptr) { + if (node && node->data && node->data->address == ptr) { if (is_env_status == ANOTHER_MEMCHECK_QUIET_NOT_EXISTS) { std::clog << " id: " << node->data->id << std::endl; } @@ -141,6 +141,7 @@ namespace SC_AM_Internal { std::clog << "WARNING: Attempted free of unknown memory location!\n"; } else { result = true; + real_free(ptr); } }