mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibWeb: Fix memory leak in CSS::ImageStyleValue
Before this change, whenever ImageStyleValue had a non-null `m_image_request`, it was always leaked along with everything related to the document to which this value belongs. The issue arises due to the use of `JS::Handle` for the image request, as it introduces a cyclic dependency where `ImageRequest` prevents the `CSSStyleSheet`, that owns `ImageStyleValue`, from being deallocated: - ImageRequest - FetchController - FetchParams - Window - HTMLDocument - HTMLHtmlElement - HTMLBodyElement - Text - HTMLHeadElement - Text - HTMLMetaElement - Text - HTMLTitleElement - Text - HTMLStyleElement - CSSStyleSheet This change solves this by visiting `m_image_request` from `visit_edges` instead of introducing new heap root by using `JS::Handle`.
This commit is contained in:
committed by
Alexander Kalenik
parent
d81b0e3c86
commit
707ca984bd
@@ -9,6 +9,7 @@
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
@@ -38,6 +39,15 @@ PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(JS::Realm&
|
||||
{
|
||||
}
|
||||
|
||||
void PropertyOwningCSSStyleDeclaration::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
for (auto& property : m_properties) {
|
||||
if (property.value->is_image())
|
||||
property.value->as_image().visit_edges(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
String PropertyOwningCSSStyleDeclaration::item(size_t index) const
|
||||
{
|
||||
if (index >= m_properties.size())
|
||||
|
||||
Reference in New Issue
Block a user