From bfc6623bbd0c94632769e346002845548b03d9e6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 3 Dec 2021 03:38:33 +0100 Subject: [PATCH] Make SWIG_CException dtor public to fix memory leak The actual dtor was never called when the wrapper object was destroyed before, due to dtor being private. --- Lib/c/cexcept.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/c/cexcept.swg b/Lib/c/cexcept.swg index 3a317d65e..8c9545657 100644 --- a/Lib/c/cexcept.swg +++ b/Lib/c/cexcept.swg @@ -22,6 +22,7 @@ extern "C" void SWIG_CException_Raise(int code, const char* msg); class SWIG_CException { public: SWIG_CException(const SWIG_CException& ex) throw() : code(ex.code), msg(strdup(ex.msg)) { } + ~SWIG_CException() { free(const_cast(msg)); } const int code; const char* const msg; @@ -43,7 +44,6 @@ private: static thread_local SWIG_CException* PendingException; SWIG_CException(int code, const char* msg) : code(code), msg(strdup(msg)) { } - ~SWIG_CException() { free(const_cast(msg)); } SWIG_CException& operator=(const SWIG_CException& ex); };