Cast ApkAssets to uintptr_t before jlong
Ever since 1e2456730d was submitted, we
have been getting reports of leaking of fds owned by ApkAssets.
The code that invokes the finalizer in NativeAllocationRegistry uses
the following code to cast the jlong free function to the pointer of the
native free function:
void* nativePtr = reinterpret_cast<void*>(static_cast<uintptr_t>(ptr));
In ApkAssets, we should be doing the reverse of these casts to give
NativeAllocationRegistry a pointer to a free function that will be
interpreted correctly.
Bug: 178571382
Test: manual
Change-Id: I6cd3f5cc9fd3693a1288e0309e9e49b08c0d5316
This commit is contained in:
@@ -354,7 +354,7 @@ static void NativeDestroy(void* ptr) {
|
||||
}
|
||||
|
||||
static jlong NativeGetFinalizer(JNIEnv* /*env*/, jclass /*clazz*/) {
|
||||
return reinterpret_cast<jlong>(&NativeDestroy);
|
||||
return static_cast<jlong>(reinterpret_cast<uintptr_t>(&NativeDestroy));
|
||||
}
|
||||
|
||||
static jstring NativeGetAssetPath(JNIEnv* env, jclass /*clazz*/, jlong ptr) {
|
||||
|
||||
Reference in New Issue
Block a user