throw exception when Chacha.process() input array is null

pull/34/head
Chris Conlon 2022-07-29 14:09:45 -06:00
parent c51d6122a9
commit 03b7797304
1 changed files with 9 additions and 11 deletions

View File

@ -147,20 +147,18 @@ Java_com_wolfssl_wolfcrypt_Chacha_wc_1Chacha_1process(
input = getByteArray(env, input_obj);
inputSz = getByteArrayLength(env, input_obj);
if (input == NULL) {
return NULL;
}
output = (byte*)XMALLOC(inputSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (output == NULL) {
throwOutOfMemoryException(env, "Failed to allocate key buffer");
return result;
}
if (chacha == NULL) {
if (chacha == NULL || input == NULL) {
ret = BAD_FUNC_ARG;
}
if (ret == 0) {
output = (byte*)XMALLOC(inputSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (output == NULL) {
throwOutOfMemoryException(env, "Failed to allocate key buffer");
return result;
}
}
if (ret == 0) {
ret = wc_Chacha_Process(chacha, output, input, inputSz);
}