# HG changeset patch # User igerasim # Date 1532032886 25200 # Node ID c3a089b16cc94f0b76cddb2aeafbd445e7c349bb # Parent 7410cb248bbf6d861cda839ac4a360d4664b2596 8207753: Handle to process snapshot is leaked if Process32First() fails Reviewed-by: rriggs diff -r 7410cb248bbf -r c3a089b16cc9 src/java.base/windows/native/libjava/ProcessHandleImpl_win.c --- 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