winegcc: Fix memory leaks (Coverity)
Andrew Talbot
Andrew.Talbot at talbotville.com
Fri Jan 5 07:47:30 CST 2007
Changelog:
winegcc: Fix memory leaks (Coverity).
diff -urN a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
--- a/tools/winegcc/winegcc.c 2006-12-05 17:37:13.000000000 +0000
+++ b/tools/winegcc/winegcc.c 2007-01-05 13:44:45.000000000 +0000
@@ -259,6 +259,8 @@
if (opts->processor != proc_cpp)
{
+ strarray *sar = strarray_fromstring(DLLFLAGS, " ");
+
#ifdef CC_FLAG_SHORT_WCHAR
if (!opts->wine_objdir && !opts->noshortwchar)
{
@@ -266,7 +268,8 @@
strarray_add(comp_args, "-DWINE_UNICODE_NATIVE");
}
#endif
- strarray_addall(comp_args, strarray_fromstring(DLLFLAGS, " "));
+ strarray_addall(comp_args, sar);
+ strarray_free(sar);
}
#ifdef _WIN64
@@ -366,6 +369,7 @@
#undef SYS_INCLUDE
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)
@@ -429,6 +433,7 @@
static const char *stdlibpath[] = { DLLDIR, LIBDIR, "/usr/lib", "/usr/local/lib", "/lib" };
strarray *lib_dirs, *files;
strarray *spec_args, *link_args;
+ strarray *sar_space = strarray_fromstring(DLLFLAGS, " ");
char *output_file;
const char *spec_o_name;
const char *output_name, *spec_file, *lang;
@@ -571,7 +576,8 @@
strarray_add(spec_args, AS);
strarray_add(spec_args, "--ld-cmd");
strarray_add(spec_args, LD);
- strarray_addall(spec_args, strarray_fromstring(DLLFLAGS, " "));
+ strarray_addall(spec_args, sar_space);
+ strarray_free(sar_space);
strarray_add(spec_args, opts->shared ? "--dll" : "--exe");
strarray_add(spec_args, "-o");
strarray_add(spec_args, spec_o_name);
@@ -617,6 +623,7 @@
}
spawn(opts->prefix, spec_args, 0);
+ strarray_free(spec_args);
/* link everything together now */
link_args = strarray_alloc();
@@ -640,6 +647,7 @@
for ( j = 0; j < lib_dirs->size; j++ )
strarray_add(link_args, strmake("-L%s", lib_dirs->base[j]));
+ strarray_free(lib_dirs);
strarray_add(link_args, spec_o_name);
for ( j = 0; j < files->size; j++ )
@@ -657,6 +665,7 @@
break;
}
}
+ strarray_free(files);
if (!opts->nostdlib)
{
@@ -665,6 +674,7 @@
}
spawn(opts->prefix, link_args, 0);
+ strarray_free(link_args);
/* set the base address */
if (opts->image_base)
@@ -685,8 +695,11 @@
/* create the loader script */
if (generate_app_loader)
{
+ char *s = strmake("%s.exe.so", output_name);
+
if (strendswith(output_file, ".exe")) output_file[strlen(output_file) - 4] = 0;
- create_file(output_file, 0755, app_loader_template, strmake("%s.exe.so", output_name));
+ create_file(output_file, 0755, app_loader_template, s);
+ free(s);
}
}
@@ -702,6 +715,7 @@
strarray_add(args, argv[j]);
spawn(opts->prefix, args, 0);
+ strarray_free(args);
}
/*
More information about the wine-patches
mailing list