8162097: [PIT] A series of closed tests about SunFontManager throw NPE on Windows
authorprr
Mon, 25 Jul 2016 15:09:23 -0700
changeset 39874 bf85c2b8f0e0
parent 39873 76907ae1b680
child 39875 7a65bed8f877
8162097: [PIT] A series of closed tests about SunFontManager throw NPE on Windows Reviewed-by: bpb, serb
jdk/src/java.desktop/windows/native/libfontmanager/fontpath.c
--- a/jdk/src/java.desktop/windows/native/libfontmanager/fontpath.c	Mon Jul 18 15:43:30 2016 -0500
+++ b/jdk/src/java.desktop/windows/native/libfontmanager/fontpath.c	Mon Jul 25 15:09:23 2016 -0700
@@ -305,8 +305,8 @@
     familyLC = (*env)->CallObjectMethod(env, fmi->family,
                                         fmi->toLowerCaseMID, fmi->locale);
     /* Delete the created reference after its usage */
-    DeleteLocalReference(env, fmi->family);
     if ((*env)->ExceptionCheck(env)) {
+        DeleteLocalReference(env, fmi->family);
         return 0;
     }
 
@@ -317,10 +317,12 @@
                                                    familyLC);
     if ((*env)->ExceptionCheck(env)) {
         /* Delete the created references before return */
+        DeleteLocalReference(env, fmi->family);
         DeleteLocalReference(env, familyLC);
         return 0;
     } else if (mapHasKey) {
         /* Delete the created references before return */
+        DeleteLocalReference(env, fmi->family);
         DeleteLocalReference(env, familyLC);
         return 1;
     }
@@ -329,6 +331,7 @@
                                   fmi->arrayListClass, fmi->arrayListCtr, 4);
     if (fmi->list == NULL) {
         /* Delete the created references before return */
+        DeleteLocalReference(env, fmi->family);
         DeleteLocalReference(env, familyLC);
         return 0;
     }
@@ -339,6 +342,7 @@
     DeleteLocalReference(env, familyLC);
     if ((*env)->ExceptionCheck(env)) {
         /* Delete the created reference before return */
+        DeleteLocalReference(env, fmi->family);
         DeleteLocalReference(env, fmi->list);
         return 0;
     }
@@ -351,6 +355,7 @@
                         lParam, 0L);
 
     /* Delete the created reference after its usage in the enum function */
+    DeleteLocalReference(env, fmi->family);
     DeleteLocalReference(env, fmi->list);
     return 1;
 }