mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
Merge pull request #20293 from endjkv:fix-mem-leak-when-throw
* fix memory leak when exception is thrown
This commit is contained in:
parent
c95a56450d
commit
42d644ef91
@ -1835,7 +1835,15 @@ void* TLSDataContainer::getData() const
|
|||||||
{
|
{
|
||||||
// Create new data instance and save it to TLS storage
|
// Create new data instance and save it to TLS storage
|
||||||
pData = createDataInstance();
|
pData = createDataInstance();
|
||||||
getTlsStorage().setData(key_, pData);
|
try
|
||||||
|
{
|
||||||
|
getTlsStorage().setData(key_, pData);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
deleteDataInstance(pData);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return pData;
|
return pData;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user