Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Nemkin2020-01-25 05:27:39 -0500
committerNikita Nemkin2020-01-25 05:31:48 -0500
commit1a8cfba09a1af043fa79523d67f395039e99813a (patch)
tree6b1eec93425b8590d9c232a83e28db6a6272c2c3
parentab25af70a253dc101105124940579dcb4c3ce859 (diff)
downloadeclipse.platform.swt-1a8cfba09a1af043fa79523d67f395039e99813a.tar.gz
eclipse.platform.swt-1a8cfba09a1af043fa79523d67f395039e99813a.tar.xz
eclipse.platform.swt-1a8cfba09a1af043fa79523d67f395039e99813a.zip
Bug 558501 - [Win32] Reduce usage of trycatch JNI flag
trycatch swallows all native exceptions, including invalid memory access, resulting in unpredictable memory corruption. Note: trycatch flag was added in Bug 329518 (8118a2195207) to cover some mysterious crashes in third-party code. Change-Id: I86371a81bef75b718a55e671b3c7d2c292b4ab91 Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.c10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.h7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java2
4 files changed, 5 insertions, 33 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.c
index 467b8738f0..a2255ad4e8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -788,9 +788,9 @@ JNIEXPORT jint JNICALL COM_NATIVE(OleSetMenuDescriptor)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2, jlong arg3, jlong arg4)
{
jint rc = 0;
- COM_NATIVE_ENTER_TRY(env, that, OleSetMenuDescriptor_FUNC);
+ COM_NATIVE_ENTER(env, that, OleSetMenuDescriptor_FUNC);
rc = (jint)OleSetMenuDescriptor((HOLEMENU)arg0, (HWND)arg1, (HWND)arg2, (LPOLEINPLACEFRAME)arg3, (LPOLEINPLACEACTIVEOBJECT)arg4);
- COM_NATIVE_EXIT_CATCH(env, that, OleSetMenuDescriptor_FUNC);
+ COM_NATIVE_EXIT(env, that, OleSetMenuDescriptor_FUNC);
return rc;
}
#endif
@@ -1108,9 +1108,9 @@ JNIEXPORT jint JNICALL COM_NATIVE(VtblCall__IJ)
(JNIEnv *env, jclass that, jint arg0, jlong arg1)
{
jint rc = 0;
- COM_NATIVE_ENTER_TRY(env, that, VtblCall__IJ_FUNC);
+ COM_NATIVE_ENTER(env, that, VtblCall__IJ_FUNC);
rc = (jint)((jint (STDMETHODCALLTYPE *)(jlong))(*(jlong **)arg1)[arg0])(arg1);
- COM_NATIVE_EXIT_CATCH(env, that, VtblCall__IJ_FUNC);
+ COM_NATIVE_EXIT(env, that, VtblCall__IJ_FUNC);
return rc;
}
#endif
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.h
index c6784f9e60..7b2dbb08bd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.h
@@ -20,11 +20,4 @@
#define COM_LOAD_FUNCTION LOAD_FUNCTION
-#define COM_NATIVE_ENTER_TRY(env, that, func) \
- COM_NATIVE_ENTER(env, that, func); \
- NATIVE_TRY(env, that, func);
-#define COM_NATIVE_EXIT_CATCH(env, that, func) \
- NATIVE_CATCH(env, that, func); \
- COM_NATIVE_EXIT(env, that, func);
-
#endif /* INC_com_H */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
index 60808257d2..f0453030c8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h
@@ -43,23 +43,4 @@
#include "os_custom.h"
-#define NATIVE_TRY(env, that, func) \
- __try {
-#define NATIVE_CATCH(env, that, func) \
- } __except(EXCEPTION_EXECUTE_HANDLER) { \
- jclass expClass = (*env)->FindClass(env, "org/eclipse/swt/SWTError"); \
- if (expClass) { \
- char buffer[64]; \
- wsprintfA(buffer, "caught native exception: 0x%x", GetExceptionCode()); \
- (*env)->ThrowNew(env, expClass, buffer); \
- } \
- }
-
-#define OS_NATIVE_ENTER_TRY(env, that, func) \
- OS_NATIVE_ENTER(env, that, func); \
- NATIVE_TRY(env, that, func);
-#define OS_NATIVE_EXIT_CATCH(env, that, func) \
- NATIVE_CATCH(env, that, func); \
- OS_NATIVE_EXIT(env, that, func);
-
#endif /* INC_os_H */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java
index 3786d2b462..68e981875f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java
@@ -386,7 +386,6 @@ public static final native int OleSetClipboard(long pDataObject);
/** @param pUnk cast=(LPUNKNOWN) */
public static final native int OleSetContainedObject(long pUnk, boolean fContained);
/**
- * @method flags=trycatch
* @param holemenu cast=(HOLEMENU)
* @param hwndFrame cast=(HWND)
* @param hwndActiveObject cast=(HWND)
@@ -456,7 +455,6 @@ public static final native void VariantInit(long pvarg);
/** @param pStg cast=(IStorage *) */
public static final native int WriteClassStg(long pStg, GUID rclsid);
-/** @method flags=trycatch */
public static final native int VtblCall(int fnNumber, long ppVtbl);
public static final native int VtblCall(int fnNumber, long ppVtbl, int arg0);
public static final native int VtblCall(int fnNumber, long ppVtbl, long arg0);

Back to the top