git.annexia.org
/
libguestfs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
bcd2dba
)
ocaml: Fix memory leak in bindings for functions that return buffers.
author
Richard W.M. Jones
<rjones@redhat.com>
Tue, 29 Nov 2011 17:13:17 +0000
(17:13 +0000)
committer
Richard W.M. Jones
<rjones@redhat.com>
Tue, 29 Nov 2011 17:13:17 +0000
(17:13 +0000)
RBufferOut binding didn't free the buffer after copying it onto
the OCaml heap.
Found by valgrind.
generator/generator_ocaml.ml
patch
|
blob
|
history
diff --git
a/generator/generator_ocaml.ml
b/generator/generator_ocaml.ml
index
4f7548c
..
10c18e3
100644
(file)
--- a/
generator/generator_ocaml.ml
+++ b/
generator/generator_ocaml.ml
@@
-625,6
+625,7
@@
copy_table (char * const * argv)
| RBufferOut _ ->
pr " rv = caml_alloc_string (size);\n";
pr " memcpy (String_val (rv), r, size);\n";
| RBufferOut _ ->
pr " rv = caml_alloc_string (size);\n";
pr " memcpy (String_val (rv), r, size);\n";
+ pr " free (r);\n"
);
pr " CAMLreturn (rv);\n";
);
pr " CAMLreturn (rv);\n";