From: Richard W.M. Jones Date: Tue, 29 Nov 2011 17:13:17 +0000 (+0000) Subject: ocaml: Fix memory leak in bindings for functions that return buffers. X-Git-Tag: 1.15.8~10 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=6bd0eec12f2e39360847bfe7a9f50628cc89ed8e;hp=bcd2dba76efa4da4edb1b04f6348b0a0dfb109c2;p=libguestfs.git ocaml: Fix memory leak in bindings for functions that return buffers. RBufferOut binding didn't free the buffer after copying it onto the OCaml heap. Found by valgrind. --- diff --git a/generator/generator_ocaml.ml b/generator/generator_ocaml.ml index 4f7548c..10c18e3 100644 --- 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"; + pr " free (r);\n" ); pr " CAMLreturn (rv);\n";