mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb: Disallow creating a FileAPI::FileList with a vector of files
This factory forced callers to make a list of GC-allocated FileAPI::File objects. This isn't safe - this opens a window for these files to be garbage collected before the FileList object stores / visits the list. Instead, only allow creating an empty FileList and incrementally adding files to that list.
This commit is contained in:
parent
a3a69b8ad2
commit
8b4d28b5fd
Notes:
github-actions[bot]
2024-08-19 11:30:30 +00:00
Author: https://github.com/trflynn89
Commit: 8b4d28b5fd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1111
3 changed files with 8 additions and 21 deletions
|
@ -14,23 +14,11 @@ namespace Web::FileAPI {
|
|||
|
||||
JS_DEFINE_ALLOCATOR(FileList);
|
||||
|
||||
JS::NonnullGCPtr<FileList> FileList::create(JS::Realm& realm, Vector<JS::NonnullGCPtr<File>>&& files)
|
||||
{
|
||||
return realm.heap().allocate<FileList>(realm, realm, move(files));
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<FileList> FileList::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<FileList>(realm, realm);
|
||||
}
|
||||
|
||||
FileList::FileList(JS::Realm& realm, Vector<JS::NonnullGCPtr<File>>&& files)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, m_files(move(files))
|
||||
{
|
||||
m_legacy_platform_object_flags = LegacyPlatformObjectFlags { .supports_indexed_properties = 1 };
|
||||
}
|
||||
|
||||
FileList::FileList(JS::Realm& realm)
|
||||
: Bindings::PlatformObject(realm)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue