From 4cd7c896a623efb8db3980bca9c68f928c798ddf Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Fri, 3 May 2019 18:50:54 -0700 Subject: [PATCH] Revert "MemoryIntArray: don't double close." The reverted change causes a regression where we can get an IllegalStateException during finalization as we are adopting the native fd in a ParcelFileDescriptor which takes ownership of the fd. However, the order of finalization is undefined and if the ParcelFileDescriptor is finalized before the MemoryIntArray we would get an exception when running the finalization of the latter. This reverts commit 89dfbfa269d32534a0b110593a2ed7e7183d21a7. bug:124056170 --- core/jni/android_util_MemoryIntArray.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/jni/android_util_MemoryIntArray.cpp b/core/jni/android_util_MemoryIntArray.cpp index b68f9eca70cde..2dfbe3ecfef6a 100644 --- a/core/jni/android_util_MemoryIntArray.cpp +++ b/core/jni/android_util_MemoryIntArray.cpp @@ -142,6 +142,8 @@ static void android_util_MemoryIntArray_close(JNIEnv* env, jobject clazz, jint f jniThrowException(env, "java/io/IOException", "ashmem unpinning failed"); return; } + + close(fd); } static jint android_util_MemoryIntArray_get(JNIEnv* env, jobject clazz,