summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorLucas CHOLLET <lucas.chollet@free.fr>2023-03-21 21:57:08 -0400
committerAndreas Kling <kling@serenityos.org>2023-03-22 08:52:48 +0100
commita9cc61224d7a58d2f83473b8c09a88e63b9a9c5b (patch)
tree6de2dc022de6460c4813ad84391bfc5f0db1fda7 /Userland/Libraries/LibGUI
parent2a410f8985ca28a334a20ceaa54e9288cc377cb2 (diff)
downloadserenity-a9cc61224d7a58d2f83473b8c09a88e63b9a9c5b.zip
LibGUI: Resolve use-after-free error
Objects taken by reference are no longer valid when used in `deferred_invoke`. Explicitly copying them solve the issue.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/FileSystemModel.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp
index 8ca43ac867..a9207ac449 100644
--- a/Userland/Libraries/LibGUI/FileSystemModel.cpp
+++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp
@@ -729,7 +729,7 @@ bool FileSystemModel::fetch_thumbnail_for(Node const& node)
auto const on_error = [path, update_progress](Error error) -> void {
// Note: We need to defer that to avoid the function removing its last reference
// i.e. trying to destroy itself, which is prohibited.
- Core::EventLoop::current().deferred_invoke([&] {
+ Core::EventLoop::current().deferred_invoke([path, error = Error::copy(error)]() mutable {
s_thumbnail_cache.with_locked([path, error = move(error)](auto& cache) {
if (error != Error::from_errno(ECANCELED)) {
cache.thumbnail_cache.set(path, nullptr);