1 message in com.mysql.lists.ndb-connectorsRev 298: Fixed segfault when throwing...
FromSent OnAttachments
Monty Taylor26 Nov 2007 00:34 
Subject:Rev 298: Fixed segfault when throwing some exceptions. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel
From:Monty Taylor (mtay@mysql.com)
Date:11/26/2007 12:34:46 AM
List:com.mysql.lists.ndb-connectors

At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel

------------------------------------------------------------ revno: 298 revision-id: mtay@mysql.com-20071126083456-58o1neaum496m62g parent: mtay@mysql.com-20071126031308-7p9f1djqk2b06x5w committer: Monty Taylor <mtay@mysql.com> branch nick: devel timestamp: Mon 2007-11-26 00:34:56 -0800 message: Fixed segfault when throwing some exceptions. modified: java/ndbj.i ndbj.i-20070913223244-5938mztpztyn9sry-1 === modified file 'java/ndbj.i' --- a/java/ndbj.i 2007-11-25 05:15:15 +0000 +++ b/java/ndbj.i 2007-11-26 08:34:56 +0000 @@ -71,7 +71,7 @@ if ((mid == NULL) || (mid == 0)) { jenv->DeleteGlobalRef(callback_data->obj); jclass clazz = jenv->FindClass("java/lang/RuntimeException"); - jenv->ThrowNew(clazz,"No callback method!"); + jenv->ThrowNew(clazz,"Invalid exception class specified"); }

jenv->CallVoidMethod(callback_data->obj,mid,(jlong)result,trans,callback_data->create_time); @@ -86,8 +86,12 @@ void ndb_throw_exception(JNIEnv *jenv, const char * excp, const char *msg) { jclass clazz = NULL; const char * prefix = "com/mysql/cluster/ndbj/"; - if (strncmp(excp,"com.",4)) { + if (strncmp(excp,"com.",4)==0) { clazz = jenv->FindClass(excp); + if (clazz==NULL) + clazz = jenv->FindClass("java/lang/RuntimeException"); + jenv->ThrowNew(clazz,"Invalid exception class specified"); + return; } else { char * exception = (char *)malloc(strlen(excp)+strlen(prefix)+1); strcpy(exception,prefix); @@ -95,6 +99,10 @@

clazz = jenv->FindClass(exception); free(exception); + if (clazz==NULL) + clazz = jenv->FindClass("java/lang/RuntimeException"); + jenv->ThrowNew(clazz,"Invalid exception class specified"); + return; }

jenv->ThrowNew(clazz,msg); @@ -104,8 +112,12 @@ void ndb_throw_exception(JNIEnv *jenv, const char * excp, const char *msg,
NdbError & err) { jclass clazz = NULL; const char * prefix = "com/mysql/cluster/ndbj/"; - if (strncmp(excp,"com.",4)) { + if (strncmp(excp,"com.",4)==0) { clazz = jenv->FindClass(excp); + if (clazz==NULL) + clazz = jenv->FindClass("java/lang/RuntimeException"); + jenv->ThrowNew(clazz,"No callback method!"); + return; } else { char * exception = (char *)malloc(strlen(excp)+strlen(prefix)+1); strcpy(exception,prefix); @@ -113,6 +125,10 @@

clazz = jenv->FindClass(exception); free(exception); + if (clazz==NULL) + clazz = jenv->FindClass("java/lang/RuntimeException"); + jenv->ThrowNew(clazz,"Invalid exception class specified"); + return; }

jlong errPtr = 0;