From: Martin Quinson Date: Mon, 7 Apr 2014 00:08:34 +0000 (+0200) Subject: fix a segfault when Host.getByName(null) is called X-Git-Tag: v3_11~88^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/13ee46b3a96091710df934f6af7e87170f3f2eef?ds=sidebyside fix a segfault when Host.getByName(null) is called --- diff --git a/src/bindings/java/jmsg_host.c b/src/bindings/java/jmsg_host.c index 81ed7f7340..a7d54a38b0 100644 --- a/src/bindings/java/jmsg_host.c +++ b/src/bindings/java/jmsg_host.c @@ -69,11 +69,11 @@ Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls, jobject jhost; /* global reference to the java host instance returned */ /* get the C string from the java string */ - const char *name = (*env)->GetStringUTFChars(env, jname, 0); - if (name == NULL) { + if (jname == NULL) { jxbt_throw_null(env,bprintf("No host can have a null name")); return NULL; } + const char *name = (*env)->GetStringUTFChars(env, jname, 0); /* get the host by name (the hosts are created during the grid resolution) */ host = MSG_get_host_by_name(name);