diff options
| author | 2020-12-21 14:21:01 +0000 | |
|---|---|---|
| committer | 2020-12-21 14:21:01 +0000 | |
| commit | e064abcb16842b29d9c3bafdc18f00a76ce9560e (patch) | |
| tree | 40da9fcac33c499d958f2e26ccbe36667771654c | |
| parent | be6fa87d8c70a52c1ff39d0fa5f4c870b47e634c (diff) | |
| parent | 10308250167f75aa252a68ee12c03b0b3210c7a5 (diff) | |
Merge "Implement Drop for WpIBinder, to avoid memory leak." am: 1030825016
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1531633
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: If92d0f5a6db95f43cb0863cce13b47ac02164825
| -rw-r--r-- | libs/binder/rust/src/proxy.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libs/binder/rust/src/proxy.rs b/libs/binder/rust/src/proxy.rs index 9d612a43f4..17af0992e2 100644 --- a/libs/binder/rust/src/proxy.rs +++ b/libs/binder/rust/src/proxy.rs @@ -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 { |