mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
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:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user