File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
espresso/src/com.oracle.truffle.espresso.native/src Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -458,6 +458,10 @@ jint GetJavaVM(JNIEnv *env, JavaVM **vmPtr) {
458458 if (vmPtr == NULL ) {
459459 return JNI_ERR ;
460460 }
461+ if (env == NULL ) {
462+ fprintf (stderr , "GetJavaVM: Passed JNIEnv* is NULL" OS_NEWLINE_STR );
463+ return JNI_ERR ;
464+ }
461465
462466 moka_env = (MokapotEnv * ) (* env )-> reserved1 ;
463467 if (moka_env == NULL ) {
@@ -494,16 +498,17 @@ JNIEXPORT JNIEnv* JNICALL initializeNativeContext(void* (*fetch_by_name)(const c
494498 struct JNINativeInterface_ * jni_impl = malloc (sizeof (* jni_impl ));
495499 struct NespressoEnv * nespresso_env = (struct NespressoEnv * ) malloc (sizeof (* nespresso_env ));
496500
501+ jni_impl -> reserved0 = nespresso_env ;
502+ jni_impl -> reserved1 = NULL ;
503+ jni_impl -> reserved2 = NULL ;
504+ jni_impl -> reserved3 = NULL ;
497505 int fnCount = sizeof (* jni_impl ) / sizeof (void * );
498- int i ;
499- for (i = 0 ; i < fnCount ; ++ i ) {
506+ for (int i = 4 ; i < fnCount ; ++ i ) {
500507 ((void * * )jni_impl )[i ] = & unset_function_error ;
501508 }
502509
503510 * env = jni_impl ;
504511
505- jni_impl -> reserved0 = nespresso_env ;
506-
507512 // Fetch Java ... varargs methods.
508513 #define INIT_VARARGS_METHOD__ (fn_name ) \
509514 *(void**)(&nespresso_env->fn_name) = fetch_by_name(#fn_name);
You can’t perform that action at this time.
0 commit comments