C backend: fix passing NULL arrays to native methods

This commit is contained in:
Alexey Andreev 2019-04-26 12:40:51 +03:00
parent f828d049c4
commit 8cd96d2da2
2 changed files with 2 additions and 1 deletions

View File

@ -507,7 +507,7 @@ public class CodeGenerationVisitor implements ExprVisitor, StatementVisitor {
writer.print(")");
stringTemporaries.add(tmp);
} else if (isPrimitiveArray(type)) {
writer.print("ARRAY_DATA(");
writer.print("ARRAY_DATAN(");
expr.getArguments().get(i).acceptVisitor(this);
writer.print(", ").printStrictType(((ValueType.Array) type).getItemType()).print(")");
} else if (isPrimitiveBuffer(type)) {

View File

@ -66,6 +66,7 @@ static inline int32_t compare_double(double a, double b) {
#define ALIGN(addr, alignment) ((void*) (((uintptr_t) (addr) + ((alignment) - 1)) / (alignment) * (alignment)))
#define ARRAY_LENGTH(array) (((JavaArray*) (array))->size)
#define ARRAY_DATA(array, type) ((type*) ALIGN((((JavaArray*) (array)) + 1), sizeof(type)))
#define ARRAY_DATAN(array, type) (array != NULL ? ARRAY_DATA(array, type) : NULL)
#define ARRAY_AT(array, type, index) (((type*) ARRAY_DATA(array, type))[index])
static void* throwClassCastException();