Skip to content

Commit

Permalink
Prevent accessing of global c++ objects once they are deleted
Browse files Browse the repository at this point in the history
Fixes (Maybe) softhsm#729.
Reset objects_deleted after reset is called.
  • Loading branch information
nhorman authored and Emantor committed Mar 13, 2024
1 parent 913e7bf commit 6c5ec8d
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/SoftHSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@

// Initialise the one-and-only instance

int objects_deleted = 0;

#ifdef HAVE_CXX11

std::unique_ptr<MutexFactory> MutexFactory::instance(nullptr);
Expand Down Expand Up @@ -406,6 +408,8 @@ void SoftHSM::reset()
{
if (instance.get())
instance.reset();

objects_deleted = 0;
}

// Constructor
Expand Down Expand Up @@ -445,6 +449,7 @@ SoftHSM::~SoftHSM()

isInitialised = false;

objects_deleted = 1;
resetMutexFactoryCallbacks();
}

Expand Down
Loading

0 comments on commit 6c5ec8d

Please sign in to comment.