fixes critical memory leak when using cxMapFree() on a kv-list that is using destructors

Sat, 06 Dec 2025 15:55:53 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 06 Dec 2025 15:55:53 +0100
changeset 1545
7822ffe65848
parent 1544
8fc6f4cdc5b0
child 1546
c8dd35f3ea53

fixes critical memory leak when using cxMapFree() on a kv-list that is using destructors

CHANGELOG file | annotate | diff | comparison | revisions
docs/Writerside/topics/about.md file | annotate | diff | comparison | revisions
src/kv_list.c file | annotate | diff | comparison | revisions
--- a/CHANGELOG	Sat Dec 06 15:50:55 2025 +0100
+++ b/CHANGELOG	Sat Dec 06 15:55:53 2025 +0100
@@ -4,7 +4,8 @@
  * adds cx_system_page_size() to allocator.h
  * changes cxBufferReserve() to allow reducing the capacity
  * changes the members of CxJson and CxJsonValue
- * fix that cxReallocate(), cxReallocateArray(), cx_reallocate(), and cx_reallocatearray()
+ * fixes critical memory leak when using cxMapFree() on a kv-list that is using destructors
+ * fixes that cxReallocate(), cxReallocateArray(), cx_reallocate(), and cx_reallocatearray()
    were not returning zero after freeing the memory when passed a size of zero
 
 Version 3.2 - 2025-11-30
--- a/docs/Writerside/topics/about.md	Sat Dec 06 15:50:55 2025 +0100
+++ b/docs/Writerside/topics/about.md	Sat Dec 06 15:55:53 2025 +0100
@@ -31,7 +31,8 @@
 * adds cx_system_page_size() to allocator.h
 * changes cxBufferReserve() to allow reducing the capacity
 * changes the members of CxJson and CxJsonValue
-* fix that cxReallocate(), cxReallocateArray(), cx_reallocate(), and cx_reallocatearray()
+* fixes critical memory leak when using cxMapFree() on a kv-list that is using destructors
+* fixes that cxReallocate(), cxReallocateArray(), cx_reallocate(), and cx_reallocatearray()
   were not returning zero after freeing the memory when passed a size of zero
 
 ### Version 3.2 - 2025-11-30 {collapsible="true"}
--- a/src/kv_list.c	Sat Dec 06 15:50:55 2025 +0100
+++ b/src/kv_list.c	Sat Dec 06 15:55:53 2025 +0100
@@ -285,6 +285,7 @@
 
 static void cx_kvl_map_deallocate(struct cx_map_s *map) {
     cx_kv_list *kv_list = ((struct cx_kv_list_map_s*)map)->list;
+    cx_kv_list_update_destructors(kv_list);
     kv_list->map_methods->deallocate(map);
     kv_list->list_methods->deallocate(&kv_list->list.base);
 }

mercurial