aboutsummaryrefslogtreecommitdiff
path: root/tccpp.c
diff options
context:
space:
mode:
authorgrischka <grischka>2016-11-11 20:25:13 +0100
committergrischka <grischka>2016-11-11 20:25:13 +0100
commit59216d3db0bbf8c213124587c5549dc6025f2af2 (patch)
treed6f88b5c2d076abec477bd7762f0683124de1366 /tccpp.c
parent7c28c9b13f7c924c18920b51f42b1119c3b1e2ee (diff)
downloadtinycc-59216d3db0bbf8c213124587c5549dc6025f2af2.tar.gz
tinycc-59216d3db0bbf8c213124587c5549dc6025f2af2.tar.bz2
tccgen: fix inline_functions double free fix
Diffstat (limited to 'tccpp.c')
-rw-r--r--tccpp.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/tccpp.c b/tccpp.c
index 0bfeaeb..d2b8e96 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1072,11 +1072,17 @@ ST_FUNC int *tok_str_dup(TokenString *s)
return str;
}
-ST_FUNC void tok_str_free(int *str)
+ST_FUNC void tok_str_free_str(int *str)
{
tal_free(tokstr_alloc, str);
}
+ST_FUNC void tok_str_free(TokenString *str)
+{
+ tok_str_free_str(str->str);
+ tal_free(tokstr_alloc, str);
+}
+
ST_FUNC int *tok_str_realloc(TokenString *s, int new_size)
{
int *str, size;
@@ -1123,8 +1129,7 @@ ST_FUNC void end_macro(void)
if (str->alloc == 2) {
str->alloc = 3; /* just mark as finished */
} else {
- tok_str_free(str->str);
- tal_free(tokstr_alloc, str);
+ tok_str_free(str);
}
}
@@ -1328,7 +1333,7 @@ ST_FUNC void free_defines(Sym *b)
while (define_stack != b) {
Sym *top = define_stack;
define_stack = top->prev;
- tok_str_free(top->d);
+ tok_str_free_str(top->d);
define_undef(top);
sym_free(top);
}
@@ -3138,10 +3143,10 @@ static int macro_subst_tok(
for (i = 0; i < ws_str.len; i++)
tok_str_add(tok_str, ws_str.str[i]);
}
- tok_str_free(ws_str.str);
+ tok_str_free_str(ws_str.str);
return 0;
} else {
- tok_str_free(ws_str.str);
+ tok_str_free_str(ws_str.str);
}
next_nomacro(); /* eat '(' */
@@ -3208,7 +3213,7 @@ static int macro_subst_tok(
sa = args;
while (sa) {
sa1 = sa->prev;
- tok_str_free(sa->d);
+ tok_str_free_str(sa->d);
sym_free(sa);
sa = sa1;
}
@@ -3223,7 +3228,7 @@ static int macro_subst_tok(
*nested_list = sa1->prev;
sym_free(sa1);
if (mstr != s->d)
- tok_str_free(mstr);
+ tok_str_free_str(mstr);
}
return 0;
}
@@ -3400,7 +3405,7 @@ no_subst:
}
}
if (macro_str1)
- tok_str_free(macro_str1);
+ tok_str_free_str(macro_str1);
}
@@ -3542,7 +3547,7 @@ ST_FUNC void tccpp_delete(TCCState *s)
/* free static buffers */
cstr_free(&tokcstr);
cstr_free(&cstr_buf);
- tok_str_free(tokstr_buf.str);
+ tok_str_free_str(tokstr_buf.str);
/* free allocators */
tal_delete(toksym_alloc);