8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 16:43:03 +01:00

Fixed UB caused by 0f8e7c18 - avoid storing dangling pointer to lambda

This commit is contained in:
AlexPeshkoff 2024-08-14 16:57:20 +03:00
parent b8e75b87a7
commit 60a6f2a733
2 changed files with 20 additions and 2 deletions

View File

@ -331,7 +331,25 @@ public:
}
private:
F& clean;
F clean;
};
class CleanupFunction
{
typedef void Func();
public:
CleanupFunction(Func* clFunc)
: clean(clFunc)
{ }
~CleanupFunction()
{
clean();
}
private:
Func* clean;
};
} //namespace Firebird

View File

@ -145,7 +145,7 @@ namespace
#ifndef DEBUG_INIT
// This instance ensures dtors run when program exits
Firebird::Cleanup global(allClean);
Firebird::CleanupFunction global(allClean);
#endif //DEBUG_INIT