8035866: [parfait] JNI exception pending in jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp
Reviewed-by: serb, pchelko
--- a/jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp Fri Apr 11 11:03:13 2014 -0700
+++ b/jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp Mon Apr 14 21:24:45 2014 +0400
@@ -354,17 +354,26 @@
initThreadInfoIndex();
xorCompClass = (jclass)env->NewGlobalRef(XORComp);
+ if (env->ExceptionCheck()) {
+ return;
+ }
tc = env->FindClass("java/lang/Thread");
DASSERT(tc != NULL);
+ CHECK_NULL(tc);
+
threadClass = (jclass)env->NewGlobalRef(tc);
DASSERT(threadClass != NULL);
+ CHECK_NULL(threadClass);
+
currentThreadMethodID =
env->GetStaticMethodID(threadClass,
"currentThread", "()Ljava/lang/Thread;");
DASSERT(currentThreadMethodID != NULL);
}
+#undef ExceptionOccurred
+
/*
* Class: sun_java2d_windows_GDIWindowSurfaceData
* Method: initOps
@@ -394,6 +403,9 @@
wsdo->invalid = JNI_FALSE;
wsdo->lockType = WIN32SD_LOCK_UNLOCKED;
wsdo->peer = env->NewWeakGlobalRef(peer);
+ if (env->ExceptionOccurred()) {
+ return;
+ }
wsdo->depth = depth;
wsdo->pixelMasks[0] = redMask;
wsdo->pixelMasks[1] = greenMask;
@@ -997,7 +1009,7 @@
ThreadGraphicsInfo *info = GetThreadGraphicsInfo(env, wsdo);
GDIWinSD_InitDC(env, wsdo, info, type, patrop, clip, comp, color);
- return info->hDC;
+ return env->ExceptionCheck() ? (HDC)NULL : info->hDC;
}
JNIEXPORT void JNICALL
@@ -1056,8 +1068,14 @@
int topInset = wsdo->insets.top;
Region_StartIteration(env, &clipInfo);
jint numrects = Region_CountIterationRects(&clipInfo);
- RGNDATA *lpRgnData = (RGNDATA *) SAFE_SIZE_STRUCT_ALLOC(safe_Malloc,
+ RGNDATA *lpRgnData;
+ try {
+ lpRgnData = (RGNDATA *) SAFE_SIZE_STRUCT_ALLOC(safe_Malloc,
sizeof(RGNDATAHEADER), numrects, sizeof(RECT));
+ } catch (std::bad_alloc&) {
+ JNU_ThrowOutOfMemoryError(env, "Initialization of surface region data failed.");
+ return;
+ }
const DWORD nCount = sizeof(RGNDATAHEADER) + numrects * sizeof(RECT);
lpRgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
lpRgnData->rdh.iType = RDH_RECTANGLES;
@@ -1086,6 +1104,9 @@
env->DeleteWeakGlobalRef(info->clip);
}
info->clip = env->NewWeakGlobalRef(clip);
+ if (env->ExceptionCheck()) {
+ return;
+ }
}
// init composite