Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix a segfault when Host.getByName(null) is called
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 7 Apr 2014 00:08:34 +0000 (02:08 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 7 Apr 2014 00:09:26 +0000 (02:09 +0200)
src/bindings/java/jmsg_host.c

index 81ed7f7..a7d54a3 100644 (file)
@@ -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 */
   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;
   }
        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);
 
   /* get the host by name       (the hosts are created during the grid resolution) */
   host = MSG_get_host_by_name(name);