1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:07:34 +00:00

LibWeb: Make ListOfAvailableImages actually visit images during GC

Instead of making the "Entry" inner struct GC-allocated and marking
*that*, we now mark the image instead.

This fixes an issue found by ASAN on https://mozilla.com/
This commit is contained in:
Andreas Kling 2023-12-23 18:17:04 +01:00
parent f4fa37afd2
commit f953a70965
3 changed files with 19 additions and 39 deletions

View file

@ -33,32 +33,28 @@ public:
mutable Optional<u32> cached_hash;
};
struct Entry final : public JS::Cell {
JS_CELL(Entry, Cell);
JS_DECLARE_ALLOCATOR(Entry);
struct Entry {
Entry(JS::NonnullGCPtr<DecodedImageData> image_data, bool ignore_higher_layer_caching)
: image_data(move(image_data))
, ignore_higher_layer_caching(ignore_higher_layer_caching)
{
}
public:
static JS::NonnullGCPtr<Entry> create(JS::VM&, JS::NonnullGCPtr<DecodedImageData>, bool ignore_higher_layer_caching);
~Entry();
bool ignore_higher_layer_caching { false };
JS::NonnullGCPtr<DecodedImageData> image_data;
private:
Entry(JS::NonnullGCPtr<DecodedImageData>, bool ignore_higher_layer_caching);
bool ignore_higher_layer_caching { false };
};
ListOfAvailableImages();
~ListOfAvailableImages();
ErrorOr<void> add(Key const&, JS::NonnullGCPtr<DecodedImageData>, bool ignore_higher_layer_caching);
void add(Key const&, JS::NonnullGCPtr<DecodedImageData>, bool ignore_higher_layer_caching);
void remove(Key const&);
[[nodiscard]] JS::GCPtr<Entry> get(Key const&) const;
[[nodiscard]] Entry* get(Key const&);
void visit_edges(JS::Cell::Visitor& visitor) override;
private:
HashMap<Key, JS::NonnullGCPtr<Entry>> m_images;
HashMap<Key, NonnullOwnPtr<Entry>> m_images;
};
}