From eb6e9dde678964aaf923a651e405f01a00eccb91 Mon Sep 17 00:00:00 2001 From: Stuart-Swan <140192252+Stuart-Swan@users.noreply.github.com> Date: Mon, 16 Sep 2024 14:07:07 -0700 Subject: [PATCH] Update nvhls_array.h Fix memory leak in make_permanent function. --- cmod/include/nvhls_array.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmod/include/nvhls_array.h b/cmod/include/nvhls_array.h index bc3bb09c..730ca926 100644 --- a/cmod/include/nvhls_array.h +++ b/cmod/include/nvhls_array.h @@ -44,8 +44,9 @@ static const char* make_permanent(const char* s) { #ifdef __SYNTHESIS__ return s; #else - std::string* str = new std::string(s); // this is an intentional memory leak.. - return str->c_str(); + static std::vector vec_str; + vec_str.push_back(std::string(s)); + return vec_str.back().c_str(); #endif }