From 8e5458caea3f58664dd001d65bbda5e12482a8ae Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 1 Aug 2016 07:59:06 +0200 Subject: VPP-229: fix NPE in JNI array handling Change-Id: Ieb5182a7a3612e09bd2b28eb6a4abbdb4d29d34b Signed-off-by: Marek Gradzki --- vpp-api/java/jvpp/gen/jvpp_c_gen.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'vpp-api') diff --git a/vpp-api/java/jvpp/gen/jvpp_c_gen.py b/vpp-api/java/jvpp/gen/jvpp_c_gen.py index 60e75b1a2e6..4d0ea0b51d1 100644 --- a/vpp-api/java/jvpp/gen/jvpp_c_gen.py +++ b/vpp-api/java/jvpp/gen/jvpp_c_gen.py @@ -107,7 +107,7 @@ u64_struct_setter_template = Template(""" mp->${c_name} = clib_host_to_net_u64(${java_name});""") u8_array_struct_setter_template = Template(""" - { + if (${java_name}) { jsize cnt = (*env)->GetArrayLength (env, ${java_name}); size_t max_size = ${field_length}; if (max_size != 0 && cnt > max_size) cnt = max_size; @@ -117,7 +117,7 @@ u8_array_struct_setter_template = Template(""" u16_array_struct_setter_template = Template(""" jshort * ${java_name}ArrayElements = (*env)->GetShortArrayElements(env, ${java_name}, NULL); - { + if (${java_name}) { size_t _i; jsize cnt = (*env)->GetArrayLength (env, ${java_name}); size_t max_size = ${field_length}; @@ -131,7 +131,7 @@ u16_array_struct_setter_template = Template(""" u32_array_struct_setter_template = Template(""" jint * ${java_name}ArrayElements = (*env)->GetIntArrayElements(env, ${java_name}, NULL); - { + if (${java_name}) { size_t _i; jsize cnt = (*env)->GetArrayLength (env, ${java_name}); size_t max_size = ${field_length}; @@ -145,7 +145,7 @@ u32_array_struct_setter_template = Template(""" u64_array_struct_setter_template = Template(""" jlong * ${java_name}ArrayElements = (*env)->GetLongArrayElements(env, ${java_name}, NULL); - { + if (${java_name}) { size_t _i; jsize cnt = (*env)->GetArrayLength (env, ${java_name}); size_t max_size = ${field_length}; -- cgit 1.2.3-korg