Mercurial > hg > release > icedtea7-forest-2.6 > jdk
changeset 9993:4646d1205c04
8242695: Enhanced buffer support
Reviewed-by: alanb, rhalade
author | bpb |
---|---|
date | Wed, 20 May 2020 13:56:21 -0700 |
parents | 754f4b281b02 |
children | e8dc3ef4f0c0 |
files | src/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java |
diffstat | 2 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java Fri Sep 11 16:12:45 2020 +0000 +++ b/src/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java Wed May 20 13:56:21 2020 -0700 @@ -57,10 +57,15 @@ // query HKEY_CLASSES_ROOT\<ext> String key = filename.substring(dot); - NativeBuffer keyBuffer = WindowsNativeDispatcher.asNativeBuffer(key); - NativeBuffer nameBuffer = WindowsNativeDispatcher.asNativeBuffer("Content Type"); + NativeBuffer keyBuffer = null; + NativeBuffer nameBuffer = null; try { + keyBuffer = WindowsNativeDispatcher.asNativeBuffer(key); + nameBuffer = WindowsNativeDispatcher.asNativeBuffer("Content Type"); return queryStringValue(keyBuffer.address(), nameBuffer.address()); + } catch (WindowsException we) { + we.rethrowAsIOException(file.toString()); + return null; // keep compiler happy } finally { nameBuffer.release(); keyBuffer.release();
--- a/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java Fri Sep 11 16:12:45 2020 +0000 +++ b/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java Wed May 20 13:56:21 2020 -0700 @@ -1093,7 +1093,12 @@ private static final Unsafe unsafe = Unsafe.getUnsafe(); - static NativeBuffer asNativeBuffer(String s) { + static NativeBuffer asNativeBuffer(String s) throws WindowsException { + if (s.length() > (Integer.MAX_VALUE - 2)/2) { + throw new WindowsException + ("String too long to convert to native buffer"); + } + int stringLengthInBytes = s.length() << 1; int sizeInBytes = stringLengthInBytes + 2; // char terminator