diff options
author | Erik Hennig <online@erik-hennig.me> | 2024-08-26 09:33:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-26 07:33:23 +0000 |
commit | e5caa725da54e58aa2e545f2a975def10d943ec5 (patch) | |
tree | f597bff568fb98dc067cb1f8f440a7ad09df27bf /components/script/script_runtime.rs | |
parent | c028b5c2993aceba5c4268e95d01e9dc56baeca7 (diff) | |
download | servo-e5caa725da54e58aa2e545f2a975def10d943ec5.tar.gz servo-e5caa725da54e58aa2e545f2a975def10d943ec5.zip |
Fix a memory leak in `components/script/script_runtime.rs` and add more leak suppressions (#33175)
* asan: Add suppression for known false positive
Signed-off-by: ede1998 <online@erik-hennig.me>
* fix: re-suppress lazy_static leaks
lazy_static is still used by dependencies and still leaks
from static variables.
Signed-off-by: ede1998 <online@erik-hennig.me>
* fix: Memory leak of Box<NetworkingTaskSource>
Signed-off-by: ede1998 <online@erik-hennig.me>
---------
Signed-off-by: ede1998 <online@erik-hennig.me>
Diffstat (limited to 'components/script/script_runtime.rs')
-rw-r--r-- | components/script/script_runtime.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index bc1f8f7e1bc..3f9cdf8a1bb 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -444,6 +444,7 @@ pub struct Runtime { rt: RustRuntime, pub microtask_queue: Rc<MicrotaskQueue>, job_queue: *mut JobQueue, + networking_task_src: Option<Box<NetworkingTaskSource>>, } impl Drop for Runtime { @@ -561,12 +562,13 @@ unsafe fn new_rt_and_cx_with_parent( networking_task_src.queue_unconditionally(task).is_ok() } + let mut networking_task_src_ptr = std::ptr::null_mut(); if let Some(source) = networking_task_source { - let networking_task_src = Box::new(source); + networking_task_src_ptr = Box::into_raw(Box::new(source)); InitDispatchToEventLoop( cx, Some(dispatch_to_event_loop), - Box::into_raw(networking_task_src) as *mut c_void, + networking_task_src_ptr as *mut c_void, ); } @@ -721,6 +723,8 @@ unsafe fn new_rt_and_cx_with_parent( rt: runtime, microtask_queue, job_queue, + networking_task_src: (!networking_task_src_ptr.is_null()) + .then(|| Box::from_raw(networking_task_src_ptr)), } } |