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.
This commit is contained in:
Stephen Seo 2024-06-27 14:00:39 +09:00
parent 3169bc0458
commit 23b851d8f3
3 changed files with 9 additions and 2 deletions

View file

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.7) cmake_minimum_required(VERSION 3.7)
project(AnotherMemCheck) project(AnotherMemCheck)
set(AnotherMemCheck_VERSION 2.2) set(AnotherMemCheck_VERSION 2.4)
set(AnotherMemCheck_SOVERSION 2) set(AnotherMemCheck_SOVERSION 2)
set(AnotherMemCheck_SOURCES set(AnotherMemCheck_SOURCES

View file

@ -1,5 +1,11 @@
# Changelog # Changelog
## Version 2.4
Fixed free() not actually calling real_free().
Fixed nullptr dereference during free.
## Version 2.3 ## Version 2.3
Added ids to each chunk of allocated memory to make it easier to keep track of Added ids to each chunk of allocated memory to make it easier to keep track of

View file

@ -43,7 +43,7 @@ namespace SC_AM_Internal {
ListNode *node = head; ListNode *node = head;
while (node != nullptr) { while (node != nullptr) {
node = node->next; 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) { if (is_env_status == ANOTHER_MEMCHECK_QUIET_NOT_EXISTS) {
std::clog << " id: " << node->data->id << std::endl; 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"; std::clog << "WARNING: Attempted free of unknown memory location!\n";
} else { } else {
result = true; result = true;
real_free(ptr);
} }
} }