aboutsummaryrefslogtreecommitdiff
path: root/pc.y
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-09-20 19:37:13 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-09-20 19:37:13 -0400
commit944512372b71c0a03639264896e791d80e3b0143 (patch)
tree2b407070d3ea6aae7a810c88a0dd9c129963a3a6 /pc.y
parentb0fa80e34881152350d3994eb1d28687d4d47d84 (diff)
Fix removes some string duplication
Diffstat (limited to 'pc.y')
-rw-r--r--pc.y5
1 files changed, 4 insertions, 1 deletions
diff --git a/pc.y b/pc.y
index ec78f22..a264286 100644
--- a/pc.y
+++ b/pc.y
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <stddef.h>
#include <assert.h>
+#include <string.h>
#include "node.h"
#include "scope.h"
@@ -201,7 +202,9 @@ sub_prog_head
tmp->var_type = $5;
- cur_scope->ret_var = scope_insert(cur_scope, $2);
+ /* Need to duplicate ID.name so it is not freed with inner
+ * scope*/
+ cur_scope->ret_var = scope_insert(cur_scope, strdup($2));
cur_scope->ret_var->var_type = $5;
}
|PROC ID arguments ';'