Salome HOME
Suppress memory leak when using Kernel_Utils::decode()
[modules/smesh.git] / src / SMESH / SMESH_Gen.cxx
index 4e24447b3aa70407dedeba452cd812ef5c9516cd..65e59d98dfdb38e53223261b42b0937910621293 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -1077,18 +1077,14 @@ std::vector< std::string > SMESH_Gen::GetPluginXMLPaths()
       xmlPath += sep + plugin + ".xml";
       bool fileOK;
 #ifdef WIN32
-  #ifdef UNICODE
+#  ifdef UNICODE
       const wchar_t* path = Kernel_Utils::decode_s(xmlPath);
-  #else
+      SMESHUtils::ArrayDeleter<const wchar_t> deleter( path );
+#  else
       const char* path = xmlPath.c_str();
-  #endif
-
+#  endif
       fileOK = (GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES);
 
-  #ifdef UNICODE
-      delete path;
-  #endif
-
 #else
       fileOK = (access(xmlPath.c_str(), F_OK) == 0);
 #endif