diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-04-14 08:43:47 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-04-14 18:55:59 +0200 |
commit | 781287c1e38aa55f3bb283ead7a9b3776c340b77 (patch) | |
tree | 2174a8281f2069cf3e3cb82ac73ea2e92e8abb79 /Userland/Libraries/LibWeb | |
parent | 9be5dcfd89d19326e5feb6045c35953285d48e84 (diff) | |
download | serenity-781287c1e38aa55f3bb283ead7a9b3776c340b77.zip |
LibWeb: Do not dereference empty Optional in ReadableStream::visit_edges
There are quite a few steps between a ReadableStream being created and
its controller being set. If GC occurs between those points, we will
have an empty Optional in ReadableStream::visit_edges. Seen on YouTube.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/Streams/ReadableStream.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp index ef321ad4cb..de150649c6 100644 --- a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp +++ b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp @@ -108,7 +108,8 @@ JS::ThrowCompletionOr<void> ReadableStream::initialize(JS::Realm& realm) void ReadableStream::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); - m_controller->visit([&](auto& controller) { visitor.visit(controller); }); + if (m_controller.has_value()) + m_controller->visit([&](auto& controller) { visitor.visit(controller); }); visitor.visit(m_stored_error); visitor.visit(m_reader); } |