Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e8dfa3a authored by Andrew Walbran's avatar Andrew Walbran
Browse files

Implement Drop for WpIBinder, to avoid memory leak.

Bug: 175584883
Test: mm
Change-Id: I741187bb83b1f6b353df575633a64cf7aeb4112a
parent 922f4fca
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -416,6 +416,16 @@ impl WpIBinder {
    }
}

impl Drop for WpIBinder {
    fn drop(&mut self) {
        unsafe {
            // Safety: WpIBinder always holds a valid `AIBinder_Weak` pointer, so we
            // know this pointer is safe to pass to `AIBinder_Weak_delete` here.
            sys::AIBinder_Weak_delete(self.0);
        }
    }
}

/// Rust wrapper around DeathRecipient objects.
#[repr(C)]
pub struct DeathRecipient {