#3693: Compile natives as C instead of C++, check malloc/calloc return values for null

This commit is contained in:
lax1dude
2024-06-25 07:01:10 +10:00
committed by md_5
parent cda4537fba
commit 8b195d1d21
11 changed files with 122 additions and 31 deletions

View File

@@ -0,0 +1,15 @@
#include "shared.h"
#include <stdlib.h>
#include <stdio.h>
void throwOutOfMemoryError(JNIEnv* env, const char* msg) {
jclass exceptionClass = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
if (!exceptionClass) {
// If the proxy ran out of memory, loading this class may fail
fprintf(stderr, "OUT OF MEMORY: %s\n", msg);
fprintf(stderr, "Could not load class java.lang.OutOfMemoryError!\n");
exit(-1);
return;
}
(*env)->ThrowNew(env, exceptionClass, msg);
}