[PATCH] winegcc: Free the temporary string arrays (Coverity)
Marcus Meissner
marcus at jet.franken.de
Tue Feb 10 02:51:07 CST 2009
Hi,
This fixes CID 883, 882, 881, 880, 879, 878, 877,
which are all basically missing strarray_free(arr)s.
Also the "const" in get_translator was overly optimistic
I think, since it returns newly allocated lists.
Ciao, Marcus
---
tools/winegcc/winegcc.c | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index 08929a3..9a68d7f 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -282,7 +282,7 @@ static char* get_temp_file(const char* prefix, const char* suffix)
return tmp;
}
-static const strarray* get_translator(struct options *opts)
+static strarray* get_translator(struct options *opts)
{
const char *str;
@@ -303,8 +303,10 @@ static void compile(struct options* opts, const char* lang)
strarray* comp_args = strarray_alloc();
unsigned int j;
int gcc_defs = 0;
+ strarray* translator = get_translator(opts);
- strarray_addall(comp_args, get_translator(opts));
+ strarray_addall(comp_args, translator);
+ strarray_free (translator);
switch(opts->processor)
{
case proc_cpp: gcc_defs = 1; break;
@@ -438,6 +440,7 @@ no_compat_defines:
strarray_add(comp_args, strmake("-I%s/include", opts->wine_objdir) );
spawn(opts->prefix, comp_args, 0);
+ strarray_free(comp_args);
}
static const char* compile_to_object(struct options* opts, const char* file, const char* lang)
@@ -501,6 +504,7 @@ static void build(struct options* opts)
static const char *stdlibpath[] = { DLLDIR, LIBDIR, "/usr/lib", "/usr/local/lib", "/lib" };
strarray *lib_dirs, *files;
strarray *spec_args, *link_args;
+ strarray *tmparray;
char *output_file;
const char *spec_o_name;
const char *output_name, *spec_file, *lang;
@@ -692,11 +696,18 @@ static void build(struct options* opts)
}
spawn(opts->prefix, spec_args, 0);
+ strarray_free (spec_args);
/* link everything together now */
link_args = strarray_alloc();
- strarray_addall(link_args, get_translator(opts));
- strarray_addall(link_args, strarray_fromstring(LDDLLFLAGS, " "));
+
+ tmparray = get_translator(opts);
+ strarray_addall(link_args, tmparray);
+ strarray_free(tmparray);
+
+ tmparray = strarray_fromstring(LDDLLFLAGS, " ");
+ strarray_addall(link_args, tmparray);
+ strarray_free(tmparray);
strarray_add(link_args, "-o");
strarray_add(link_args, strmake("%s.so", output_file));
@@ -755,6 +766,7 @@ static void build(struct options* opts)
}
spawn(opts->prefix, link_args, 0);
+ strarray_free (link_args);
/* set the base address */
if (opts->image_base)
@@ -784,14 +796,17 @@ static void build(struct options* opts)
static void forward(int argc, char **argv, struct options* opts)
{
strarray* args = strarray_alloc();
+ strarray* translator = get_translator(opts);
int j;
- strarray_addall(args, get_translator(opts));
+ strarray_addall(args, translator);
+ strarray_free(translator);
for( j = 1; j < argc; j++ )
strarray_add(args, argv[j]);
spawn(opts->prefix, args, 0);
+ strarray_free (args);
}
/*
--
1.5.6
More information about the wine-patches
mailing list