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.