--- a/jdk/src/windows/native/sun/windows/ShellFolder2.cpp Tue Mar 04 11:43:12 2014 +0400
+++ b/jdk/src/windows/native/sun/windows/ShellFolder2.cpp Tue Mar 04 13:40:58 2014 +0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -219,10 +219,15 @@
return;
}
MID_pIShellFolder = env->GetMethodID(cls, "setIShellFolder", "(J)V");
+ CHECK_NULL(MID_pIShellFolder);
FID_pIShellIcon = env->GetFieldID(cls, "pIShellIcon", "J");
+ CHECK_NULL(FID_pIShellIcon);
MID_relativePIDL = env->GetMethodID(cls, "setRelativePIDL", "(J)V");
+ CHECK_NULL(MID_relativePIDL);
FID_displayName = env->GetFieldID(cls, "displayName", "Ljava/lang/String;");
+ CHECK_NULL(FID_displayName);
FID_folderType = env->GetFieldID(cls, "folderType", "Ljava/lang/String;");
+ CHECK_NULL(FID_folderType);
}
@@ -719,8 +724,9 @@
// Get relative PIDL for name
LPITEMIDLIST pIDL;
int nLength = env->GetStringLength(jname);
+ const jchar* strPath = env->GetStringChars(jname, NULL);
+ JNU_CHECK_EXCEPTION_RETURN(env, 0);
jchar* wszPath = new jchar[nLength + 1];
- const jchar* strPath = env->GetStringChars(jname, NULL);
wcsncpy(reinterpret_cast<LPWSTR>(wszPath), reinterpret_cast<LPCWSTR>(strPath), nLength);
wszPath[nLength] = 0;
HRESULT res = pIShellFolder->ParseDisplayName(NULL, NULL,
@@ -811,6 +817,7 @@
HICON hIcon = NULL;
SHFILEINFO fileInfo;
LPCTSTR pathStr = JNU_GetStringPlatformChars(env, absolutePath, NULL);
+ JNU_CHECK_EXCEPTION_RETURN(env, 0);
if (fn_SHGetFileInfo(pathStr, 0L, &fileInfo, sizeof(fileInfo),
SHGFI_ICON | (getLargeIcon ? 0 : SHGFI_SMALLICON)) != 0) {
hIcon = fileInfo.hIcon;
@@ -954,9 +961,11 @@
ReleaseDC(NULL, dc);
// Create java array
iconBits = env->NewIntArray(nBits);
+ if (!(env->ExceptionCheck())) {
// Copy values to java array
env->SetIntArrayRegion(iconBits, 0, nBits, colorBits);
}
+ }
// Fix 4745575 GDI Resource Leak
// MSDN
// GetIconInfo creates bitmaps for the hbmMask and hbmColor members of ICONINFO.
@@ -1028,6 +1037,7 @@
jint cxDesired, jint cyDesired, jboolean useVGAColors)
{
const char *pLibName = env->GetStringUTFChars(libName, NULL);
+ JNU_CHECK_EXCEPTION_RETURN(env, 0);
HINSTANCE libHandle = (HINSTANCE)JDK_LoadSystemLibrary(pLibName);
if (libHandle != NULL) {
UINT fuLoad = (useVGAColors && !IS_WINXP) ? LR_VGACOLOR : 0;
@@ -1046,8 +1056,11 @@
jclass *pClass, jmethodID *pConstructor,
SHELLDETAILS *psd, ULONG visible)
{
+ jstring str = jstringFromSTRRET(pEnv, NULL, &(psd->str));
+ JNU_CHECK_EXCEPTION_RETURN(pEnv, NULL);
+
return pEnv->NewObject(*pClass, *pConstructor,
- jstringFromSTRRET(pEnv, NULL, &(psd->str)),
+ str,
(jint)(psd->cxChar * 6), // TODO: is 6 OK for converting chars to pixels?
(jint)psd->fmt, (jboolean) visible);
}
@@ -1115,6 +1128,10 @@
jobject column = CreateColumnInfo(env,
&columnClass, &columnConstructor,
&sd, csFlags & SHCOLSTATE_ONBYDEFAULT);
+ if(!column){
+ pIShellFolder2->Release();
+ return NULL;
+ }
env->SetObjectArrayElement(columns, (jsize) colNum, column);
}
}
@@ -1155,6 +1172,10 @@
jobject column = CreateColumnInfo(env,
&columnClass, &columnConstructor,
&sd, 1);
+ if(!column){
+ pIShellDetails->Release();
+ return NULL;
+ }
env->SetObjectArrayElement(columns, (jsize) colNum++, column);
}
}