From 17d0610d00a0b84640d06e470e4baffa4a176e25 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 23 Feb 2019 04:05:03 -0700 Subject: [PATCH] [OCaml] Fix possible memory leaks in generated dispatch functions All paths now free argv. --- Source/Modules/ocaml.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 8b248bad2..7e59def7f 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -752,7 +752,7 @@ public: Printv(df->code, "argv = (CAML_VALUE *)malloc( argc * sizeof( CAML_VALUE ) );\n" "for( i = 0; i < argc; i++ ) {\n" " argv[i] = caml_list_nth(args,i);\n" "}\n", NIL); - Printv(df->code, dispatch, "\n", NIL); + Printv(df->code, dispatch, "\nfree(argv);\n", NIL); Node *sibl = n; while (Getattr(sibl, "sym:previousSibling")) sibl = Getattr(sibl, "sym:previousSibling");