From e472044e24b0727b90452b8f5a15a4793986aeba Mon Sep 17 00:00:00 2001 From: Foster Brereton Date: Wed, 4 Feb 2026 15:14:11 -0800 Subject: [PATCH] Fix undefined behavior in string_pool memory management The string_pool_t destructor was using delete on memory allocated with ::operator new, which is undefined behavior. Memory allocated with ::operator new must be deallocated with ::operator delete. Changes: - Replace adobe::for_each(pool_m, adobe::delete_ptr()) with explicit loop using ::operator delete - Remove unused includes: adobe/algorithm/for_each.hpp and adobe/functional.hpp Co-Authored-By: Claude Opus 4.5 --- source/string_pool.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/string_pool.cpp b/source/string_pool.cpp index 59603e5e..c99d6786 100644 --- a/source/string_pool.cpp +++ b/source/string_pool.cpp @@ -13,9 +13,7 @@ #include #include -#include #include -#include #include #include @@ -43,7 +41,11 @@ class string_pool_t : boost::noncopyable { explicit string_pool_t(std::size_t pool_size = default_pool_size_k) : pool_size_m(pool_size), next_m(NULL), end_m(NULL) {} - ~string_pool_t() { adobe::for_each(pool_m, adobe::delete_ptr()); } + ~string_pool_t() { + for (char* pool : pool_m) { + ::operator delete(pool); + } + } const char* add(const char* ident) { std::size_t n = std::strlen(ident);