aboutsummaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-09-20 19:21:33 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-09-20 19:21:33 -0400
commitb0fa80e34881152350d3994eb1d28687d4d47d84 (patch)
tree0c518467f9f2b5d6ee53d7596f64c6e8c8c37771 /tree.c
parent174208192d8ebd0f43e18cba978257ec74ead14a (diff)
Fix double free of array info
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tree.c b/tree.c
index d218eed..d59fd18 100644
--- a/tree.c
+++ b/tree.c
@@ -64,7 +64,8 @@ void update_type_info(list, t)
ptree *list, *t;
{
int type;
- struct ai *info = NULL;
+ struct ai *info, *tmp;
+ info = tmp = NULL;
assert(list && t);
type = t->type;
@@ -82,9 +83,14 @@ ptree *list, *t;
} else while (list->r && list->r->type == ID) {
/*Set type of right child through list*/
list->r->attr.nval->var_type = type;
- if (info)
+ if (info){
list->r->attr.nval->array_info = info;
+ assert(tmp = malloc(sizeof(struct ai)));
+ memcpy(tmp, info, sizeof(struct ai));
+ info = tmp;
+ }
+
if (list->l) {
if (list->l->type == LIST) {
list = list->l;
@@ -95,6 +101,10 @@ ptree *list, *t;
list->l->attr.nval->var_type = type;
if (info){
list->l->attr.nval->array_info = info;
+
+ assert(tmp = malloc(sizeof(struct ai)));
+ memcpy(tmp, info, sizeof(struct ai));
+ info = tmp;
}
}
}