mirror of
https://github.com/zebrajr/ladybird.git
synced 2026-01-15 12:15:15 +00:00
LibWeb: Don't store GC::Root<JS::ArrayBuffer> in FileAPI::FileReader
This was creating a reference cycle and leaking the realm.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
b291d75289
commit
2d2078d439
@@ -51,6 +51,9 @@ void FileReader::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_error);
|
||||
m_result.visit(
|
||||
[&](GC::Ref<JS::ArrayBuffer> const& array_buffer) { visitor.visit(array_buffer); },
|
||||
[](auto&) {});
|
||||
}
|
||||
|
||||
GC::Ref<FileReader> FileReader::create(JS::Realm& realm)
|
||||
|
||||
@@ -21,7 +21,7 @@ class FileReader : public DOM::EventTarget {
|
||||
GC_DECLARE_ALLOCATOR(FileReader);
|
||||
|
||||
public:
|
||||
using Result = Variant<Empty, String, GC::Root<JS::ArrayBuffer>>;
|
||||
using Result = Variant<Empty, String, GC::Ref<JS::ArrayBuffer>>;
|
||||
|
||||
virtual ~FileReader() override;
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ GC::Ref<FileReaderSync> FileReaderSync::construct_impl(JS::Realm& realm)
|
||||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#dfn-readAsArrayBufferSync
|
||||
WebIDL::ExceptionOr<GC::Root<JS::ArrayBuffer>> FileReaderSync::read_as_array_buffer(Blob& blob)
|
||||
WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> FileReaderSync::read_as_array_buffer(Blob& blob)
|
||||
{
|
||||
return read_as<GC::Root<JS::ArrayBuffer>>(blob, FileReader::Type::ArrayBuffer);
|
||||
return read_as<GC::Ref<JS::ArrayBuffer>>(blob, FileReader::Type::ArrayBuffer);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#dfn-readAsBinaryStringSync
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
[[nodiscard]] static GC::Ref<FileReaderSync> create(JS::Realm&);
|
||||
static GC::Ref<FileReaderSync> construct_impl(JS::Realm&);
|
||||
|
||||
WebIDL::ExceptionOr<GC::Root<JS::ArrayBuffer>> read_as_array_buffer(Blob&);
|
||||
WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> read_as_array_buffer(Blob&);
|
||||
WebIDL::ExceptionOr<String> read_as_binary_string(Blob&);
|
||||
WebIDL::ExceptionOr<String> read_as_text(Blob&, Optional<String> const& encoding = {});
|
||||
WebIDL::ExceptionOr<String> read_as_data_url(Blob&);
|
||||
|
||||
Reference in New Issue
Block a user