Skip to content

Commit c09c433

Browse files
committed
8292866: Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation check MultiByteToWideChar return value for failures
Reviewed-by: goetz Backport-of: 699c42962eeaa6aa950ad86c2dd1f77316a1da3e
1 parent 03e1247 commit c09c433

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
700700
STRRET strret;
701701
OLECHAR olePath[MAX_PATH]; // wide-char version of path name
702702
LPWSTR wstr;
703+
int ret;
703704

704705
IShellFolder* pParent = (IShellFolder*)parentIShellFolder;
705706
if (pParent == NULL) {
@@ -719,12 +720,18 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
719720
switch (strret.uType) {
720721
case STRRET_CSTR :
721722
// IShellFolder::ParseDisplayName requires the path name in Unicode.
722-
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strret.cStr, -1, olePath, MAX_PATH);
723+
ret = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strret.cStr, -1, olePath, MAX_PATH);
724+
if (ret == 0) {
725+
return NULL;
726+
}
723727
wstr = olePath;
724728
break;
725729

726730
case STRRET_OFFSET :
727-
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (CHAR *)pidl + strret.uOffset, -1, olePath, MAX_PATH);
731+
ret = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (CHAR *)pidl + strret.uOffset, -1, olePath, MAX_PATH);
732+
if (ret == 0) {
733+
return NULL;
734+
}
728735
wstr = olePath;
729736
break;
730737

0 commit comments

Comments
 (0)