From 27b85e9fc2e534f579e187431f7dd1a1cbf155a1 Mon Sep 17 00:00:00 2001 From: Andrew Werner Date: Mon, 9 Sep 2024 14:19:48 -0400 Subject: [PATCH] frida-gum: unref Interceptor on Drop Without this, the acquired reference would leak. --- frida-gum/src/interceptor.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frida-gum/src/interceptor.rs b/frida-gum/src/interceptor.rs index d5693d0..6c6868b 100644 --- a/frida-gum/src/interceptor.rs +++ b/frida-gum/src/interceptor.rs @@ -26,6 +26,12 @@ pub struct Interceptor<'a> { phantom: PhantomData<&'a gum_sys::GumInterceptor>, } +impl Drop for Interceptor<'_> { + fn drop(&mut self) { + unsafe { frida_gum_sys::g_object_unref(self.interceptor as *mut _) } + } +} + impl<'a> Interceptor<'a> { /// Obtain an Interceptor handle, ensuring that the runtime is properly initialized. This may /// be called as many times as needed, and results in a no-op if the Interceptor is