Skip to content

Commit

Permalink
added runtime checks in java.c
Browse files Browse the repository at this point in the history
  • Loading branch information
xevor11 committed Aug 23, 2024
1 parent 8ac6f69 commit 70f22e1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libcob/java.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

/* Force symbol exports */
#define COB_LIB_EXPIMP
#include "common.h"
#include "libcob.h"
#include "coblocal.h"

Expand Down Expand Up @@ -77,19 +78,23 @@ resolve_java (const char *class_name,
}

cls = (*env)->FindClass(env, jni_class_name);
free(jni_class_name);
cob_free(jni_class_name);
if (!cls) {
cob_runtime_error(_("Java class '%s' not found"), class_name);
return NULL;
}

mid = (*env)->GetStaticMethodID(env, cls, method_name, method_signature);
if (!mid) {
cob_runtime_error(_("Java method '%s' with signature '%s' not found in class '%s'"),
method_name, method_signature, class_name);
(*env)->DeleteLocalRef(env, cls);
return NULL;
}

handle = (cob_java_handle*)cob_malloc(sizeof(cob_java_handle));
if (!handle) {
cob_runtime_error(_("Memory allocation failed for Java method handle"));
(*env)->DeleteLocalRef(env, cls);
return NULL;
}
Expand Down

0 comments on commit 70f22e1

Please sign in to comment.