diff --git a/tcc.c b/tcc.c index 03fac0b3..467ef880 100644 --- a/tcc.c +++ b/tcc.c @@ -35,6 +35,7 @@ static int do_bench = 0; static int gen_deps; static const char *deps_outfile; static const char *m_option; +static char *linker_arg; #define TCC_OPTION_HAS_ARG 0x0001 #define TCC_OPTION_NOSEP 0x0002 /* cannot have space before option and arg */ @@ -280,7 +281,6 @@ static int parse_args(TCCState *s, int argc, char **argv) const char *optarg, *p1, *r1; char *r; int was_pthread; - char *linker_arg = NULL; unsigned long linker_argsize = 0; was_pthread = 0; /* is set if commandline contains -pthread key */ @@ -478,7 +478,6 @@ static int parse_args(TCCState *s, int argc, char **argv) } if ((r = (char *) tcc_set_linker(s, (char *)linker_arg, TRUE))) tcc_error("unsupported linker option '%s'", r); - tcc_free(linker_arg); /* fixme: these options could be different on your platform */ if (was_pthread && output_type != TCC_OUTPUT_OBJ) { dynarray_add((void ***)&files, &nb_files, "-lpthread"); @@ -611,6 +610,7 @@ int main(int argc, char **argv) } tcc_delete(s); + tcc_free(linker_arg); tcc_free(outfile); #ifdef MEM_DEBUG