RFR [XS] : 8213366: (fs) avoid handle leak in Java_sun_nio_fs_WindowsNativeDispatcher_FindFirstFile0

Alan Bateman Alan.Bateman at oracle.com
Mon Nov 5 11:49:22 UTC 2018


On 05/11/2018 11:44, Baesken, Matthias wrote:
>
> Hello,  please   review this small fix.
>
> It adjusts
>
> Java_sun_nio_fs_WindowsNativeDispatcher_FindFirstFile0
>
> In file src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c .
>
> In this function  a  Handle  “handle”  is acquired by calling 
> FindFirstFileW  .
>
> However  we have an early  return in the function, and in this special 
> case  we miss  to close the handle  with FindClose .
>

So if NewString fails with OOME then we invoke the field setting JNI 
functions with a pending exception and leak the handle. The proposed 
change looks okay to me.

-Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20181105/d7ac7bca/attachment.html>


More information about the nio-dev mailing list