mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
LibGUI: Guard against use-after-free in Clipboard::the()
We now make sure that a VERIFY will fail if Clipboard::the() is called after the destruction of its static-local variables.
This commit is contained in:
parent
4d2357f8f3
commit
246b42b635
1 changed files with 6 additions and 0 deletions
|
@ -44,6 +44,12 @@ void Clipboard::initialize(Badge<Application>)
|
|||
|
||||
Clipboard& Clipboard::the()
|
||||
{
|
||||
static bool s_destructed = false;
|
||||
static ScopeGuard destructed_guard([] {
|
||||
s_destructed = true;
|
||||
});
|
||||
VERIFY(!s_destructed); // Catch use-after-free
|
||||
|
||||
static Clipboard s_the;
|
||||
return s_the;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue