From 070812b34be49ccf7d37fbef8010c30cfe5198a3 Mon Sep 17 00:00:00 2001 From: ajwerner Date: Wed, 11 Sep 2024 01:59:56 -0400 Subject: [PATCH] frida-gum: unref Interceptor on Drop (#153) 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 391864f..8593ff9 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