< prev index next >

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

Print this page

        

@@ -371,27 +371,25 @@
     HBITMAP hMask = ::CreateBitmap(nW, nH, 1, 1, (BYTE *)andMaskPtr);
     ::GdiFlush();
 
     int *cols = SAFE_SIZE_NEW_ARRAY2(int, nW, nH);
 
-    jint *intRasterDataPtr = NULL;
+    /* Copy the raster data because GDI may fail on some Java heap
+     * allocated memory.
+     */
+    length = env->GetArrayLength(intRasterData);
+    jint *intRasterDataPtr = new jint[length];
     HBITMAP hColor = NULL;
     try {
-        intRasterDataPtr =
-            (jint *)env->GetPrimitiveArrayCritical(intRasterData, 0);
+        env->GetIntArrayRegion(intRasterData, 0, length, intRasterDataPtr);
         hColor = create_BMP(NULL, (int *)intRasterDataPtr, nSS, nW, nH);
         memcpy(cols, intRasterDataPtr, nW*nH*sizeof(int));
     } catch (...) {
-        if (intRasterDataPtr != NULL) {
-            env->ReleasePrimitiveArrayCritical(intRasterData,
-                                               intRasterDataPtr, 0);
-        }
+        delete[] intRasterDataPtr;
         throw;
     }
-
-    env->ReleasePrimitiveArrayCritical(intRasterData, intRasterDataPtr, 0);
-    intRasterDataPtr = NULL;
+    delete[] intRasterDataPtr;
 
     HCURSOR hCursor = NULL;
 
     if (hMask && hColor) {
         ICONINFO icnInfo;
< prev index next >