LibWeb: Clear circular download reference when download finished

This commit is contained in:
Tom 2020-12-31 11:16:30 -07:00 committed by Andreas Kling
parent 084c296362
commit a4b3eb6b2d
Notes: sideshowbarker 2024-07-19 00:17:57 +09:00

View file

@ -184,7 +184,10 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
error_callback("HTTP load failed");
return;
}
deferred_invoke([&](auto&) { const_cast<RefPtr<Protocol::Download>&>(download) = nullptr; });
deferred_invoke([download](auto&) {
// Clear circular reference of `download` captured by copy
const_cast<Protocol::Download&>(*download).on_buffered_download_finish = nullptr;
});
success_callback(payload, response_headers);
};
download->set_should_buffer_all_input(true);