From 808e525d57310e1332cbf53c88c16b6359ebee7a Mon Sep 17 00:00:00 2001 From: Ytai Ben-Tsvi Date: Tue, 25 May 2021 08:20:59 -0700 Subject: [PATCH] Prevent double-closing of native handle in HidlMemory Since the handle wasn't nullified, when the memory is explicitly closed, the finalizer would attempt to close again, which results in an exception. Bug: 189213084 Test: Manual verification of ST use-cases, which uses this. Patch sent to partner for verification. Change-Id: I4ac6bbdd88b3f729a022896adfed00effec48bd8 --- core/java/android/os/HidlMemory.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/java/android/os/HidlMemory.java b/core/java/android/os/HidlMemory.java index 26fc6f0ae4ceb..2539a6b2a0eb7 100644 --- a/core/java/android/os/HidlMemory.java +++ b/core/java/android/os/HidlMemory.java @@ -79,6 +79,7 @@ public class HidlMemory implements Closeable { public void close() throws IOException { if (mHandle != null) { mHandle.close(); + mHandle = null; } }