From 02ae70474d418b202b6a8411daa54f8dfc790206 Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Fri, 11 Sep 2009 10:33:32 +0100 Subject: [PATCH] generator.ml: Fix string list memory leak Parsed string lists are allocated by malloc, but were never freed. --- src/generator.ml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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" -- 1.8.3.1