aboutsummaryrefslogtreecommitdiffstats
path: root/vpp-api
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-12-15 07:30:09 +0100
committerMarek Gradzki <mgradzki@cisco.com>2016-12-15 07:38:08 +0100
commitd4cfe15965a27fe950bee2f07c79a0376cdb80ec (patch)
tree1e1b057ca2d298f50d4f243af111b79c2fe4e4e8 /vpp-api
parentcb630ff691264f7ea4a0f52cc6faa87fcdaa1a40 (diff)
Fix NPE in JNI while handling int arrays, VPP-559
Change-Id: Idc3760b65e62cfa5d37dd7379e35331b7f95f913 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-api')
-rw-r--r--vpp-api/java/jvpp/gen/jvppgen/jni_gen.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/vpp-api/java/jvpp/gen/jvppgen/jni_gen.py b/vpp-api/java/jvpp/gen/jvppgen/jni_gen.py
index eee8660a2b0..328cc8d35d2 100644
--- a/vpp-api/java/jvpp/gen/jvppgen/jni_gen.py
+++ b/vpp-api/java/jvpp/gen/jvppgen/jni_gen.py
@@ -198,42 +198,42 @@ u8_array_struct_setter_template = Template("""
""")
u16_array_struct_setter_template = Template("""
- jshort * ${field_reference_name}ArrayElements = (*env)->GetShortArrayElements(env, ${field_reference_name}, NULL);
if (${field_reference_name}) {
+ jshort * ${field_reference_name}ArrayElements = (*env)->GetShortArrayElements(env, ${field_reference_name}, NULL);
size_t _i;
jsize cnt = (*env)->GetArrayLength (env, ${field_reference_name});
${field_length_check}
for (_i = 0; _i < cnt; _i++) {
mp->${c_name}[_i] = clib_host_to_net_u16(${field_reference_name}ArrayElements[_i]);
}
+ (*env)->ReleaseShortArrayElements (env, ${field_reference_name}, ${field_reference_name}ArrayElements, 0);
}
- (*env)->ReleaseShortArrayElements (env, ${field_reference_name}, ${field_reference_name}ArrayElements, 0);
""")
u32_array_struct_setter_template = Template("""
- jint * ${field_reference_name}ArrayElements = (*env)->GetIntArrayElements(env, ${field_reference_name}, NULL);
if (${field_reference_name}) {
+ jint * ${field_reference_name}ArrayElements = (*env)->GetIntArrayElements(env, ${field_reference_name}, NULL);
size_t _i;
jsize cnt = (*env)->GetArrayLength (env, ${field_reference_name});
${field_length_check}
for (_i = 0; _i < cnt; _i++) {
mp->${c_name}[_i] = clib_host_to_net_u32(${field_reference_name}ArrayElements[_i]);
}
+ (*env)->ReleaseIntArrayElements (env, ${field_reference_name}, ${field_reference_name}ArrayElements, 0);
}
- (*env)->ReleaseIntArrayElements (env, ${field_reference_name}, ${field_reference_name}ArrayElements, 0);
""")
u64_array_struct_setter_template = Template("""
- jlong * ${field_reference_name}ArrayElements = (*env)->GetLongArrayElements(env, ${field_reference_name}, NULL);
if (${field_reference_name}) {
+ jlong * ${field_reference_name}ArrayElements = (*env)->GetLongArrayElements(env, ${field_reference_name}, NULL);
size_t _i;
jsize cnt = (*env)->GetArrayLength (env, ${field_reference_name});
${field_length_check}
for (_i = 0; _i < cnt; _i++) {
mp->${c_name}[_i] = clib_host_to_net_u64(${field_reference_name}ArrayElements[_i]);
}
+ (*env)->ReleaseLongArrayElements (env, ${field_reference_name}, ${field_reference_name}ArrayElements, 0);
}
- (*env)->ReleaseLongArrayElements (env, ${field_reference_name}, ${field_reference_name}ArrayElements, 0);
""")
struct_setter_templates = {'u8': u8_struct_setter_template,