8189633: Missing -Xcheck:jni checking for DeleteWeakGlobalRef
authorkbarrett
Wed, 21 Aug 2019 19:21:57 -0400
changeset 57829 58891103f9cc
parent 57828 35db8fba55f9
child 57830 26ada504269a
8189633: Missing -Xcheck:jni checking for DeleteWeakGlobalRef Summary: Added validity check on the handle before deleting it. Reviewed-by: dholmes, dcubed
src/hotspot/share/prims/jniCheck.cpp
--- a/src/hotspot/share/prims/jniCheck.cpp	Wed Aug 21 18:42:30 2019 -0400
+++ b/src/hotspot/share/prims/jniCheck.cpp	Wed Aug 21 19:21:57 2019 -0400
@@ -1927,6 +1927,12 @@
   checked_jni_DeleteWeakGlobalRef(JNIEnv *env,
                                   jweak ref))
     functionEnterExceptionAllowed(thr);
+    IN_VM(
+      if (ref && !JNIHandles::is_weak_global_handle(ref)) {
+        ReportJNIFatalError(thr,
+             "Invalid weak global JNI handle passed to DeleteWeakGlobalRef");
+      }
+    )
     UNCHECKED()->DeleteWeakGlobalRef(env, ref);
     functionExit(thr);
 JNI_END