From: Matthew Booth Date: Fri, 11 Sep 2009 09:33:32 +0000 (+0100) Subject: generator.ml: Fix string list memory leak X-Git-Tag: 1.0.69~16 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=02ae70474d418b202b6a8411daa54f8dfc790206;p=libguestfs.git generator.ml: Fix string list memory leak Parsed string lists are allocated by malloc, but were never freed. --- diff --git a/src/generator.ml b/src/generator.ml index 2e2b70e..433c60a 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -6221,7 +6221,7 @@ and generate_fish_cmds () = | OptString n | FileIn n | FileOut n -> pr " const char *%s;\n" n - | StringList n | DeviceList n -> pr " char *const *%s;\n" n + | StringList n | DeviceList n -> pr " char **%s;\n" n | Bool n -> pr " int %s;\n" n | Int n -> pr " int %s;\n" n ) (snd style); @@ -6264,6 +6264,15 @@ and generate_fish_cmds () = generate_c_call_args ~handle:"g" style; pr ";\n"; + List.iter ( + function + | Pathname name | Device name | Dev_or_Path name | String name + | OptString name | FileIn name | FileOut name | Bool name + | Int name -> () + | StringList name | DeviceList name -> + pr " free_strings (%s);\n" name + ) (snd style); + (* Check return value for errors and display command results. *) (match fst style with | RErr -> pr " return r;\n"