Merge pull request #44 from jtraglia/check-malloc-ret
Check that malloc'd settings isn't null
This commit is contained in:
commit
8b0ff7a8ee
|
@ -44,7 +44,13 @@ JNIEXPORT void JNICALL Java_ethereum_ckzg4844_CKZG4844JNI_loadTrustedSetup__Ljav
|
||||||
throw_exception(env, "Trusted Setup is already loaded. Free it before loading a new one.");
|
throw_exception(env, "Trusted Setup is already loaded. Free it before loading a new one.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings = malloc(sizeof(KZGSettings));
|
settings = malloc(sizeof(KZGSettings));
|
||||||
|
if (settings == NULL)
|
||||||
|
{
|
||||||
|
throw_exception(env, "Failed to allocate memory for settings.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const char *file_native = (*env)->GetStringUTFChars(env, file, 0);
|
const char *file_native = (*env)->GetStringUTFChars(env, file, 0);
|
||||||
|
|
||||||
|
@ -78,7 +84,13 @@ JNIEXPORT void JNICALL Java_ethereum_ckzg4844_CKZG4844JNI_loadTrustedSetup___3BJ
|
||||||
throw_exception(env, "Trusted Setup is already loaded. Free it before loading a new one.");
|
throw_exception(env, "Trusted Setup is already loaded. Free it before loading a new one.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings = malloc(sizeof(KZGSettings));
|
settings = malloc(sizeof(KZGSettings));
|
||||||
|
if (settings == NULL)
|
||||||
|
{
|
||||||
|
throw_exception(env, "Failed to allocate memory for settings.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
jbyte *g1_native = (*env)->GetByteArrayElements(env, g1, NULL);
|
jbyte *g1_native = (*env)->GetByteArrayElements(env, g1, NULL);
|
||||||
jbyte *g2_native = (*env)->GetByteArrayElements(env, g2, NULL);
|
jbyte *g2_native = (*env)->GetByteArrayElements(env, g2, NULL);
|
||||||
|
|
Loading…
Reference in New Issue