util/ScopeExit: allow the function to throw

Fixes crash inside AtScopeExit() in the WASAPI output plugin.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1759
This commit is contained in:
Max Kellermann 2023-05-22 14:42:02 +02:00
parent 2fa8c7d2db
commit 2ab03a0914

View File

@ -47,7 +47,11 @@ public:
src.enabled = false;
}
~ScopeExitGuard() {
/* destructors are "noexcept" by default; this explicit
"noexcept" declaration allows the destructor to throw if
the function can throw; without this, a throwing function
would std::terminate() */
~ScopeExitGuard() noexcept(noexcept(F::operator()())) {
if (enabled)
F::operator()();
}