case RS_TYPE_FLOAT_32: \
len = _env->GetArrayLength((jfloatArray)data); \
ptr = _env->GetFloatArrayElements((jfloatArray)data, flag); \
+ if (ptr == nullptr) { \
+ ALOGE("Failed to get Java array elements."); \
+ return; \
+ } \
typeBytes = 4; \
if (usePadding) { \
srcPtr = ptr; \
case RS_TYPE_FLOAT_64: \
len = _env->GetArrayLength((jdoubleArray)data); \
ptr = _env->GetDoubleArrayElements((jdoubleArray)data, flag); \
+ if (ptr == nullptr) { \
+ ALOGE("Failed to get Java array elements."); \
+ return; \
+ } \
typeBytes = 8; \
if (usePadding) { \
srcPtr = ptr; \
case RS_TYPE_UNSIGNED_8: \
len = _env->GetArrayLength((jbyteArray)data); \
ptr = _env->GetByteArrayElements((jbyteArray)data, flag); \
+ if (ptr == nullptr) { \
+ ALOGE("Failed to get Java array elements."); \
+ return; \
+ } \
typeBytes = 1; \
if (usePadding) { \
srcPtr = ptr; \
case RS_TYPE_UNSIGNED_16: \
len = _env->GetArrayLength((jshortArray)data); \
ptr = _env->GetShortArrayElements((jshortArray)data, flag); \
+ if (ptr == nullptr) { \
+ ALOGE("Failed to get Java array elements."); \
+ return; \
+ } \
typeBytes = 2; \
if (usePadding) { \
srcPtr = ptr; \
case RS_TYPE_UNSIGNED_32: \
len = _env->GetArrayLength((jintArray)data); \
ptr = _env->GetIntArrayElements((jintArray)data, flag); \
+ if (ptr == nullptr) { \
+ ALOGE("Failed to get Java array elements."); \
+ return; \
+ } \
typeBytes = 4; \
if (usePadding) { \
srcPtr = ptr; \
case RS_TYPE_UNSIGNED_64: \
len = _env->GetArrayLength((jlongArray)data); \
ptr = _env->GetLongArrayElements((jlongArray)data, flag); \
+ if (ptr == nullptr) { \
+ ALOGE("Failed to get Java array elements."); \
+ return; \
+ } \
typeBytes = 8; \
if (usePadding) { \
srcPtr = ptr; \
jlong* jFieldIDs = _env->GetLongArrayElements(fieldIDArray, nullptr);
jsize fieldIDs_length = _env->GetArrayLength(fieldIDArray);
+ if (jFieldIDs == nullptr) {
+ ALOGE("Failed to get Java array elements: fieldIDs.");
+ return ret;
+ }
+
jlong* jValues = _env->GetLongArrayElements(valueArray, nullptr);
jsize values_length = _env->GetArrayLength(valueArray);
+ if (jValues == nullptr) {
+ ALOGE("Failed to get Java array elements: values.");
+ return ret;
+ }
+
jint* jSizes = _env->GetIntArrayElements(sizeArray, nullptr);
jsize sizes_length = _env->GetArrayLength(sizeArray);
+ if (jSizes == nullptr) {
+ ALOGE("Failed to get Java array elements: sizes.");
+ return ret;
+ }
+
jlong* jDepClosures =
_env->GetLongArrayElements(depClosureArray, nullptr);
jsize depClosures_length = _env->GetArrayLength(depClosureArray);
+ if (jDepClosures == nullptr) {
+ ALOGE("Failed to get Java array elements: depClosures.");
+ return ret;
+ }
+
jlong* jDepFieldIDs =
_env->GetLongArrayElements(depFieldIDArray, nullptr);
jsize depFieldIDs_length = _env->GetArrayLength(depFieldIDArray);
+ if (jDepFieldIDs == nullptr) {
+ ALOGE("Failed to get Java array elements: depFieldIDs.");
+ return ret;
+ }
size_t numValues, numDependencies;
RsScriptFieldID* fieldIDs;
jbyte* jParams = _env->GetByteArrayElements(paramArray, nullptr);
jsize jParamLength = _env->GetArrayLength(paramArray);
+ if (jParams == nullptr) {
+ ALOGE("Failed to get Java array elements: params.");
+ return ret;
+ }
+
jlong* jFieldIDs = _env->GetLongArrayElements(fieldIDArray, nullptr);
jsize fieldIDs_length = _env->GetArrayLength(fieldIDArray);
+ if (jFieldIDs == nullptr) {
+ ALOGE("Failed to get Java array elements: fieldIDs.");
+ return ret;
+ }
+
jlong* jValues = _env->GetLongArrayElements(valueArray, nullptr);
jsize values_length = _env->GetArrayLength(valueArray);
+ if (jValues == nullptr) {
+ ALOGE("Failed to get Java array elements: values.");
+ return ret;
+ }
+
jint* jSizes = _env->GetIntArrayElements(sizeArray, nullptr);
jsize sizes_length = _env->GetArrayLength(sizeArray);
+ if (jSizes == nullptr) {
+ ALOGE("Failed to get Java array elements: sizes.");
+ return ret;
+ }
size_t numValues;
RsScriptFieldID* fieldIDs;
jlong* jClosures = _env->GetLongArrayElements(closureArray, nullptr);
jsize numClosures = _env->GetArrayLength(closureArray);
+ if (jClosures == nullptr) {
+ ALOGE("Failed to get Java array elements: closures.");
+ return ret;
+ }
RsClosure* closures;
}
jint len = _env->GetArrayLength(str);
jbyte * cptr = (jbyte *) _env->GetPrimitiveArrayCritical(str, 0);
+ if (cptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
+
rsAssignName((RsContext)con, (void *)obj, (const char *)cptr, len);
_env->ReleasePrimitiveArrayCritical(str, cptr, JNI_ABORT);
}
ALOGD("nContextGetMessage, con(%p), len(%i)", (RsContext)con, len);
}
jint *ptr = _env->GetIntArrayElements(data, nullptr);
+ if (ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return 0;
+ }
size_t receiveLen;
uint32_t subID;
int id = rsContextGetMessage((RsContext)con,
ALOGD("nContextPeekMessage, con(%p)", (RsContext)con);
}
jint *auxDataPtr = _env->GetIntArrayElements(auxData, nullptr);
+ if (auxDataPtr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return 0;
+ }
size_t receiveLen;
uint32_t subID;
int id = rsContextPeekMessage((RsContext)con, &receiveLen, sizeof(receiveLen),
if (data) {
len = _env->GetArrayLength(data);
ptr = _env->GetIntArrayElements(data, nullptr);
+ if (ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
}
if (kLogApi) {
ALOGD("nContextSendMessage, con(%p), id(%i), len(%i)", (RsContext)con, id, len);
}
jlong *jIds = _env->GetLongArrayElements(_ids, nullptr);
+ if (jIds == nullptr) {
+ ALOGE("Failed to get Java array elements: ids");
+ return 0;
+ }
jint *jArraySizes = _env->GetIntArrayElements(_arraySizes, nullptr);
+ if (jArraySizes == nullptr) {
+ ALOGE("Failed to get Java array elements: arraySizes");
+ return 0;
+ }
RsElement *ids = (RsElement*)malloc(fieldCount * sizeof(RsElement));
uint32_t *arraySizes = (uint32_t *)malloc(fieldCount * sizeof(uint32_t));
sizeBytes);
}
jbyte *ptr = _env->GetByteArrayElements(data, nullptr);
+ if (ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
rsAllocationElementData((RsContext)con, (RsAllocation)alloc,
xoff, yoff, zoff,
lod, ptr, sizeBytes, compIdx);
sizeBytes);
}
jbyte *ptr = _env->GetByteArrayElements(data, nullptr);
+ if (ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
rsAllocationElementRead((RsContext)con, (RsAllocation)alloc,
xoff, yoff, zoff,
lod, ptr, sizeBytes, compIdx);
}
jint len = _env->GetArrayLength(data);
jbyte *ptr = _env->GetByteArrayElements(data, nullptr);
+ if (ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
rsScriptSetVarV((RsContext)con, (RsScript)script, slot, ptr, len);
_env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
}
}
jint len = _env->GetArrayLength(data);
jbyte *ptr = _env->GetByteArrayElements(data, nullptr);
+ if (ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
rsScriptGetVarV((RsContext)con, (RsScript)script, slot, ptr, len);
_env->ReleaseByteArrayElements(data, ptr, 0);
}
}
jint len = _env->GetArrayLength(data);
jbyte *ptr = _env->GetByteArrayElements(data, nullptr);
+ if (ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
jint dimsLen = _env->GetArrayLength(dims) * sizeof(int);
jint *dimsPtr = _env->GetIntArrayElements(dims, nullptr);
+ if (dimsPtr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
rsScriptSetVarVE((RsContext)con, (RsScript)script, slot, ptr, len, (RsElement)elem,
(const uint32_t*) dimsPtr, dimsLen);
_env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
jint length = _env->GetArrayLength(timeZone);
jbyte* timeZone_ptr;
timeZone_ptr = (jbyte *) _env->GetPrimitiveArrayCritical(timeZone, (jboolean *)0);
+ if (timeZone_ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
rsScriptSetTimeZone((RsContext)con, (RsScript)script, (const char *)timeZone_ptr, length);
}
jint len = _env->GetArrayLength(data);
jbyte *ptr = _env->GetByteArrayElements(data, nullptr);
+ if (ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
rsScriptInvokeV((RsContext)con, (RsScript)script, slot, ptr, len);
_env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
}
return;
}
- // TODO (b/20760800): Check in_ptr is not null
in_ptr = _env->GetLongArrayElements(ains, nullptr);
+ if (in_ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
+
if (sizeof(RsAllocation) == sizeof(jlong)) {
in_allocs = (RsAllocation*)in_ptr;
if (params != nullptr) {
param_len = _env->GetArrayLength(params);
param_ptr = _env->GetByteArrayElements(params, nullptr);
+ if (param_ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
}
RsScriptCall sc, *sca = nullptr;
if (limits != nullptr) {
limit_len = _env->GetArrayLength(limits);
limit_ptr = _env->GetIntArrayElements(limits, nullptr);
+ if (limit_ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
assert(limit_len == 6);
UNUSED(limit_len); // As the assert might not be compiled.
if (limits != nullptr) {
limit_len = _env->GetArrayLength(limits);
limit_ptr = _env->GetIntArrayElements(limits, nullptr);
+ if (limit_ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return;
+ }
// We expect to be passed an array [x1, x2] which specifies
// the sub-range for a 1-dimensional reduction.
}
script_ptr = (jbyte *)
_env->GetPrimitiveArrayCritical(scriptRef, (jboolean *)0);
+ if (script_ptr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return ret;
+ }
//rsScriptCSetText((RsContext)con, (const char *)script_ptr, length);
jint kernelsLen = _env->GetArrayLength(_kernels);
jlong *jKernelsPtr = _env->GetLongArrayElements(_kernels, nullptr);
+ if (jKernelsPtr == nullptr) {
+ ALOGE("Failed to get Java array elements: kernels");
+ return 0;
+ }
RsScriptKernelID* kernelsPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * kernelsLen);
for(int i = 0; i < kernelsLen; ++i) {
kernelsPtr[i] = (RsScriptKernelID)jKernelsPtr[i];
jint srcLen = _env->GetArrayLength(_src);
jlong *jSrcPtr = _env->GetLongArrayElements(_src, nullptr);
+ if (jSrcPtr == nullptr) {
+ ALOGE("Failed to get Java array elements: src");
+ return 0;
+ }
RsScriptKernelID* srcPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * srcLen);
for(int i = 0; i < srcLen; ++i) {
srcPtr[i] = (RsScriptKernelID)jSrcPtr[i];
jint dstkLen = _env->GetArrayLength(_dstk);
jlong *jDstkPtr = _env->GetLongArrayElements(_dstk, nullptr);
+ if (jDstkPtr == nullptr) {
+ ALOGE("Failed to get Java array elements: dstk");
+ return 0;
+ }
RsScriptKernelID* dstkPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * dstkLen);
for(int i = 0; i < dstkLen; ++i) {
dstkPtr[i] = (RsScriptKernelID)jDstkPtr[i];
jint dstfLen = _env->GetArrayLength(_dstf);
jlong *jDstfPtr = _env->GetLongArrayElements(_dstf, nullptr);
+ if (jDstfPtr == nullptr) {
+ ALOGE("Failed to get Java array elements: dstf");
+ return 0;
+ }
RsScriptKernelID* dstfPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * dstfLen);
for(int i = 0; i < dstfLen; ++i) {
dstfPtr[i] = (RsScriptKernelID)jDstfPtr[i];
jint typesLen = _env->GetArrayLength(_types);
jlong *jTypesPtr = _env->GetLongArrayElements(_types, nullptr);
+ if (jTypesPtr == nullptr) {
+ ALOGE("Failed to get Java array elements: types");
+ return 0;
+ }
RsType* typesPtr = (RsType*) malloc(sizeof(RsType) * typesLen);
for(int i = 0; i < typesLen; ++i) {
typesPtr[i] = (RsType)jTypesPtr[i];
AutoJavaStringToUTF8 shaderUTF(_env, shader);
jlong *jParamPtr = _env->GetLongArrayElements(params, nullptr);
jint paramLen = _env->GetArrayLength(params);
+ if (jParamPtr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return 0;
+ }
int texCount = _env->GetArrayLength(texNames);
AutoJavaStringArrayToUTF8 names(_env, texNames, texCount);
AutoJavaStringToUTF8 shaderUTF(_env, shader);
jlong *jParamPtr = _env->GetLongArrayElements(params, nullptr);
jint paramLen = _env->GetArrayLength(params);
+ if (jParamPtr == nullptr) {
+ ALOGE("Failed to get Java array elements");
+ return 0;
+ }
if (kLogApi) {
ALOGD("nProgramVertexCreate, con(%p), paramLen(%i)", (RsContext)con, paramLen);
jint vtxLen = _env->GetArrayLength(_vtx);
jlong *jVtxPtr = _env->GetLongArrayElements(_vtx, nullptr);
+ if (jVtxPtr == nullptr) {
+ ALOGE("Failed to get Java array elements: vtx");
+ return 0;
+ }
RsAllocation* vtxPtr = (RsAllocation*) malloc(sizeof(RsAllocation) * vtxLen);
for(int i = 0; i < vtxLen; ++i) {
vtxPtr[i] = (RsAllocation)(uintptr_t)jVtxPtr[i];
jint idxLen = _env->GetArrayLength(_idx);
jlong *jIdxPtr = _env->GetLongArrayElements(_idx, nullptr);
+ if (jIdxPtr == nullptr) {
+ ALOGE("Failed to get Java array elements: idx");
+ return 0;
+ }
RsAllocation* idxPtr = (RsAllocation*) malloc(sizeof(RsAllocation) * idxLen);
for(int i = 0; i < idxLen; ++i) {
idxPtr[i] = (RsAllocation)(uintptr_t)jIdxPtr[i];
jint primLen = _env->GetArrayLength(_prim);
jint *primPtr = _env->GetIntArrayElements(_prim, nullptr);
+ if (primPtr == nullptr) {
+ ALOGE("Failed to get Java array elements: prim");
+ return 0;
+ }
jlong id = (jlong)(uintptr_t)rsMeshCreate((RsContext)con,
(RsAllocation *)vtxPtr, vtxLen,