]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Memory leak hunting
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 17 Aug 2021 08:25:41 +0000 (10:25 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 17 Aug 2021 08:25:41 +0000 (10:25 +0200)
src/Basics/Basics_Utils.cxx

index 1d8fd16e0f7f6091deb400f0e953f76d1539deeb..e421e60624b14a5a32e805c80a32a38e4f90440a 100644 (file)
@@ -32,6 +32,8 @@
 #include <execinfo.h>
 #endif
 
+#include <memory>
+#include <functional>
 
 namespace Kernel_Utils
 {
@@ -144,7 +146,8 @@ namespace Kernel_Utils
 
   std::string encode_s(const wchar_t* decoded)
   {
-    return std::string(encode(decoded));
+    std::unique_ptr<char,std::function<void(char*)>> tmp((char *)encode(decoded),[](char *ptr) { delete [] ptr; });
+    return std::string(tmp.get());
   }
 
 #ifndef WIN32