Commit 5dc80a3d authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2836] Don't leak memory on exception

If we throw an exception from the constructor, destructor is not called.
Call the clean-up manually there, so we don't leak memory.
parent b9c101fd
......@@ -47,6 +47,10 @@ public:
holder_name_(getNextHolderName()), holding_(true)
{
if (mem_sgmt_.setNamedAddress(holder_name_.c_str(), NULL)) {
// OK. We've grown. The caller might need to be informed, so
// we throw. But then, we don't get our destructor, so we
// release the memory right away.
mem_sgmt_.clearNamedAddress(holder_name_.c_str());
isc_throw(isc::util::MemorySegmentGrown,
"Segment grown when allocating holder");
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment