From a710faebd3a65d57f12bda5becf55b82c0f662f9 Mon Sep 17 00:00:00 2001 From: Eremey Valetov Date: Sat, 28 Feb 2026 20:39:17 -0500 Subject: [PATCH] fix(eo): fix null pointer and dangling pointer bugs in eoForge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit eoForgeOperator no-arg specialization: instantiate_ptr() constructed an empty shared_ptr instead of a new Op instance, always returning nullptr. Fix: std::shared_ptr() → std::make_shared(). eoForgeMap::setup(): after deleting the old operator, emplace() silently no-ops when the key already exists, leaving a dangling pointer in the map and leaking the new allocation. Fix: assign through at() instead. --- eo/src/eoForge.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eo/src/eoForge.h b/eo/src/eoForge.h index 394071565..cd87e3aed 100644 --- a/eo/src/eoForge.h +++ b/eo/src/eoForge.h @@ -203,7 +203,7 @@ class eoForgeOperator : public eoForgeInterface std::shared_ptr instantiate_ptr( bool no_cache = true ) override { if(no_cache or _instantiated == nullptr) { - _instantiated_ptr = std::shared_ptr(); + _instantiated_ptr = std::make_shared(); } return _instantiated_ptr; } @@ -479,7 +479,7 @@ class eoForgeMap : public std::map*> delete this->at(name); // Silent on nullptr. auto pfo = new eoForgeOperator...>( std::forward(args)...); - this->emplace({name, pfo}); + this->at(name) = pfo; } /** Specialization for empty constructors. @@ -489,7 +489,7 @@ class eoForgeMap : public std::map*> { delete this->at(name); auto pfo = new eoForgeOperator; - this->emplace({name, pfo}); + this->at(name) = pfo; } virtual ~eoForgeMap()