aboutsummaryrefslogtreecommitdiff
path: root/pc.y
diff options
context:
space:
mode:
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 ';'