Skip to content

Commit

Permalink
common: Fixed bug #967.
Browse files Browse the repository at this point in the history
The std::function in sharedVariables wrapping the value's destructor can be uninitialized because
sharedVariables.resize(handle+1) in getSharedVariable() can add more than one item to the vector.
  • Loading branch information
levy committed Mar 28, 2024
1 parent 628d6a6 commit b4c92b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/inet/common/Compat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ uint64_t& SharedDataManager::getSharedCounter(const char *name, uint64_t initial
void SharedDataManager::clear()
{
for (auto& item : sharedVariables)
item.second(); // call stored destructor
if (item.second)
item.second(); // call stored destructor
sharedVariables.clear();
sharedCounters.clear();
sharedCounters.resize(MAX_NUM_COUNTERS, INVALID);
Expand Down

0 comments on commit b4c92b0

Please sign in to comment.