fix: Memory leak from CreateProxyWindowHandler (#32773)

* fix: Memory leak from CreateProxyWindowHandler

Signed-off-by: ede1998 <online@erik-hennig.me>

* fix: memory leak in WindowProxy

Signed-off-by: ede1998 <online@erik-hennig.me>

* fix: Memory leak in WindowProxyHandler through static

Signed-off-by: ede1998 <online@erik-hennig.me>

---------

Signed-off-by: ede1998 <online@erik-hennig.me>
This commit is contained in:
Erik Hennig 2024-08-01 23:16:49 +02:00 committed by GitHub
parent 501950c2e3
commit 5963695664
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 101 additions and 40 deletions

View file

@ -31,7 +31,7 @@ use js::rust::{
MutableHandleValue, ToString,
};
use js::JS_CALLEE;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use malloc_size_of::MallocSizeOfOps;
use crate::dom::bindings::codegen::PrototypeList::{MAX_PROTO_CHAIN_LENGTH, PROTO_OR_IFACE_LENGTH};
use crate::dom::bindings::codegen::{InterfaceObjectMap, PrototypeList};
@ -42,31 +42,22 @@ use crate::dom::bindings::error::throw_invalid_this;
use crate::dom::bindings::inheritance::TopTypeId;
use crate::dom::bindings::str::DOMString;
use crate::dom::bindings::trace::trace_object;
use crate::dom::windowproxy;
use crate::dom::windowproxy::WindowProxyHandler;
use crate::script_runtime::JSContext as SafeJSContext;
/// Proxy handler for a WindowProxy.
pub struct WindowProxyHandler(pub *const libc::c_void);
impl MallocSizeOf for WindowProxyHandler {
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
// FIXME(#6907) this is a pointer to memory allocated by `new` in NewProxyHandler in rust-mozjs.
0
}
}
#[derive(JSTraceable, MallocSizeOf)]
/// Static data associated with a global object.
pub struct GlobalStaticData {
#[ignore_malloc_size_of = "WindowProxyHandler does not properly implement it anyway"]
/// The WindowProxy proxy handler for this global.
pub windowproxy_handler: WindowProxyHandler,
pub windowproxy_handler: &'static WindowProxyHandler,
}
impl GlobalStaticData {
/// Creates a new GlobalStaticData.
pub fn new() -> GlobalStaticData {
GlobalStaticData {
windowproxy_handler: windowproxy::new_window_proxy_handler(),
windowproxy_handler: WindowProxyHandler::proxy_handler(),
}
}
}