Commit 60e957d0 by Mark Wielaard Committed by Michael Koch

gthread-jni.c (maybe_rethrow): Explicitly malloc and free buf.

2004-04-21  Mark Wielaard  <mark@klomp.org>

	* native/jni/gtk-peer/gthread-jni.c (maybe_rethrow): Explicitly
	malloc and free buf.

From-SVN: r80948
parent 27dd18cf
2004-04-21 Mark Wielaard <mark@klomp.org>
* native/jni/gtk-peer/gthread-jni.c (maybe_rethrow): Explicitly
malloc and free buf.
2004-04-21 Dalibor Topic <robilad@kaffe.org>
* javax/naming/AuthenticationException.java,
......
......@@ -91,23 +91,35 @@ JavaVM *gdk_vm;
static void maybe_rethrow(JNIEnv *gdk_env, char *message, char *file, int line) {
jthrowable cause;
/* rethrow if an exception happened */
if ((cause = (*gdk_env)->ExceptionOccurred(gdk_env)) != NULL) {
jstring jmessage;
jclass obj_class;
jobject obj;
jmethodID ctor;
int len;
char *buf;
/* rethrow if an exception happened */
if ((cause = (*gdk_env)->ExceptionOccurred(gdk_env)) != NULL)
{
/* allocate local message in Java */
int len = strlen(message) + strlen(file) + 25;
char buf[ len ];
len = strlen(message) + strlen(file) + 25;
buf = (char *) malloc(len);
if (buf != NULL)
{
bzero(buf, len);
sprintf(buf, "%s (at %s:%d)", message, file, line);
jmessage = (*gdk_env)->NewStringUTF(gdk_env, buf);
free(buf);
}
else
jmessage = NULL;
/* create RuntimeException wrapper object */
obj_class = (*gdk_env)->FindClass (gdk_env, "java/lang/RuntimeException");
ctor = (*gdk_env)->GetMethodID(gdk_env, obj_class, "<init>", "(Ljava/langString;Ljava/lang/Throwable)V");
obj_class = (*gdk_env)->FindClass (gdk_env,
"java/lang/RuntimeException");
ctor = (*gdk_env)->GetMethodID(gdk_env, obj_class, "<init>",
"(Ljava/langString;Ljava/lang/Throwable)V");
obj = (*gdk_env)->NewObject (gdk_env, obj_class, ctor, jmessage, cause);
/* throw it */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment