Skip to content

Commit 42d644e

Browse files
authored
Merge pull request #20293 from endjkv:fix-mem-leak-when-throw
* fix memory leak when exception is thrown
1 parent c95a564 commit 42d644e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

modules/core/src/system.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,15 @@ void* TLSDataContainer::getData() const
18351835
{
18361836
// Create new data instance and save it to TLS storage
18371837
pData = createDataInstance();
1838-
getTlsStorage().setData(key_, pData);
1838+
try
1839+
{
1840+
getTlsStorage().setData(key_, pData);
1841+
}
1842+
catch (...)
1843+
{
1844+
deleteDataInstance(pData);
1845+
throw;
1846+
}
18391847
}
18401848
return pData;
18411849
}

0 commit comments

Comments
 (0)