8214380: AwtDragSource function LoadCache misses a ReleaseLongArrayElements in special case
authormbaesken
Fri, 30 Nov 2018 13:31:31 +0100
changeset 52962 9c0231a493d6
parent 52844 de8be034dbd4
child 52963 1f1c949f55ff
8214380: AwtDragSource function LoadCache misses a ReleaseLongArrayElements in special case Reviewed-by: serb, stuefe
src/java.desktop/windows/native/libawt/windows/awt_DnDDS.cpp
--- a/src/java.desktop/windows/native/libawt/windows/awt_DnDDS.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/java.desktop/windows/native/libawt/windows/awt_DnDDS.cpp	Fri Nov 30 13:31:31 2018 +0100
@@ -394,9 +394,12 @@
         return;
     }
 
-    jboolean isCopy;
-    jlong *lFormats = env->GetLongArrayElements(formats, &isCopy),
+    jlong *lFormats = env->GetLongArrayElements(formats, 0),
         *saveFormats = lFormats;
+    if (lFormats == NULL) {
+        m_ntypes = 0;
+        return;
+    }
 
     for (i = 0, m_ntypes = 0; i < items; i++, lFormats++) {
         // Warning C4244.
@@ -422,6 +425,7 @@
         m_types = (FORMATETC *)safe_Calloc(sizeof(FORMATETC), m_ntypes);
     } catch (std::bad_alloc&) {
         m_ntypes = 0;
+        env->ReleaseLongArrayElements(formats, saveFormats, 0);
         throw;
     }