java: fix invalid memory access for FBuffer in struct lists

When convering FBuffer fields of structs in each element of the return
list, make sure to allocate enough buffer to hold also the trailing null
character.
This commit is contained in:
Pino Toscano
2017-03-02 17:32:58 +01:00
parent eeacc86a10
commit c9df2d44cd

View File

@@ -1038,7 +1038,7 @@ and generate_java_struct_list_return typ jtyp cols =
| FBuffer ->
pr " {\n";
pr " size_t len = r->val[i].%s_len;\n" name;
pr " CLEANUP_FREE char *s = malloc (len);\n";
pr " CLEANUP_FREE char *s = malloc (len + 1);\n";
pr " if (s == NULL) {\n";
pr " throw_out_of_memory (env, \"malloc\");\n";
pr " goto ret_error;\n";