Skip to content

Commit f93a6a6

Browse files
committed
fix(PropertyFileConfiguration): use RAII #5253
1 parent d5fca1c commit f93a6a6

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

Util/src/PropertyFileConfiguration.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,18 @@ void PropertyFileConfiguration::parseLine(std::istream& istr, const std::string&
179179
throw Poco::FileException("Cyclic property file include detected", absPathStr);
180180
}
181181

182-
includeStack.insert(absPathStr);
183-
try
182+
struct StackGuard
184183
{
185-
Poco::FileInputStream includeIstr(p.toString());
186-
if (!includeIstr.good())
187-
throw Poco::OpenFileException(p.toString());
188-
loadStream(includeIstr, p.parent().toString(), includeStack);
189-
}
190-
catch (...)
191-
{
192-
includeStack.erase(absPathStr);
193-
throw;
194-
}
195-
includeStack.erase(absPathStr);
184+
std::set<std::string>& stack;
185+
const std::string& key;
186+
StackGuard(std::set<std::string>& s, const std::string& k): stack(s), key(k) { stack.insert(k); }
187+
~StackGuard() { stack.erase(key); }
188+
} guard(includeStack, absPathStr);
189+
190+
Poco::FileInputStream includeIstr(p.toString());
191+
if (!includeIstr.good())
192+
throw Poco::OpenFileException(p.toString());
193+
loadStream(includeIstr, p.parent().toString(), includeStack);
196194
}
197195
}
198196
else

0 commit comments

Comments
 (0)