JDK-8207060 : Memory leak when malloc fails within WITH_UNICODE_STRING block
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows
  • Submitted: 2018-07-11
  • Updated: 2019-03-19
  • Resolved: 2018-07-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 12 JDK 8
12 b03Fixed 8u202Fixed
File src/java.base/windows/native/libjava/io_util_md.c

In pathToNTPath() a pair of macros WITH_UNICODE_STRING / END_UNICODE_STRING is used.

The former calls (*env)->GetStringChars() to acquire the string array, and the later calls (*env)->ReleaseStringChars().

Within this block memory is allocated with malloc(), and if that fails, we return from the pathToNTPath() without releasing the string array.