changeset 51854:c3a089b16cc9

8207753: Handle to process snapshot is leaked if Process32First() fails Reviewed-by: rriggs
author igerasim
date Thu, 19 Jul 2018 13:41:26 -0700
parents 7410cb248bbf
children e443c637b238
files src/java.base/windows/native/libjava/ProcessHandleImpl_win.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/windows/native/libjava/ProcessHandleImpl_win.c	Thu Jul 19 12:55:24 2018 -0700
+++ b/src/java.base/windows/native/libjava/ProcessHandleImpl_win.c	Thu Jul 19 13:41:26 2018 -0700
@@ -198,7 +198,7 @@
     } else {
         JNU_ThrowByName(env,
             "java/lang/RuntimeException", "snapshot not available");
-        return -1;
+        ppid = (DWORD)-1;
     }
     CloseHandle(hProcessSnap); // Ignore return code
     return (jlong)ppid;
@@ -267,13 +267,13 @@
                 break;
             }
             if (jparentArray != NULL) {
-                ppids  = (*env)->GetLongArrayElements(env, jparentArray, NULL);
+                ppids = (*env)->GetLongArrayElements(env, jparentArray, NULL);
                 if (ppids == NULL) {
                     break;
                 }
             }
             if (jstimesArray != NULL) {
-                stimes  = (*env)->GetLongArrayElements(env, jstimesArray, NULL);
+                stimes = (*env)->GetLongArrayElements(env, jstimesArray, NULL);
                 if (stimes == NULL) {
                     break;
                 }
@@ -315,7 +315,7 @@
     } else {
         JNU_ThrowByName(env,
             "java/lang/RuntimeException", "snapshot not available");
-        return 0;
+        count = 0;
     }
     CloseHandle(hProcessSnap);
     // If more pids than array had size for;  count will be greater than array size