Skip to content

Commit

Permalink
Safe delete pointers in ClassFinalize
Browse files Browse the repository at this point in the history
Double free seen on Ubuntu
  • Loading branch information
williamfgc committed Mar 7, 2019
1 parent ae68c4a commit d1d7176
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions thirdparty/KWSys/adios2sys/SystemTools.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4668,13 +4668,20 @@ void SystemTools::ClassInitialize()

void SystemTools::ClassFinalize()
{
delete SystemTools::TranslationMap;
auto lf_Delete = [](void*& pointer) {
if (pointer != nullptr) {
delete pointer;
pointer = nullptr;
}
};

lf_Delete(SystemTools::TranslationMap);
#ifdef _WIN32
delete SystemTools::PathCaseMap;
delete SystemTools::EnvMap;
lf_Delete(SystemTools::PathCaseMap);
lf_Delete(SystemTools::EnvMap);
#endif
#ifdef __CYGWIN__
delete SystemTools::Cyg2Win32Map;
lf_Delete(SystemTools::Cyg2Win32Map);
#endif
}

Expand Down

0 comments on commit d1d7176

Please sign in to comment.