Skip to content

Commit 0289ebc

Browse files
committed
Fix double mem free in param str
1 parent 62c4d04 commit 0289ebc

6 files changed

Lines changed: 1941 additions & 1 deletion

File tree

src/api/check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def is_block_accessed(block):
420420
def is_temporary_value(node) -> bool:
421421
""" Returns if the AST node value is a variable or a temporary copy in the heap.
422422
"""
423-
return node.token not in ('STRING', 'VAR') and node.t[0] not in ('_', '#')
423+
return node.token not in ('PARAMDECL', 'STRING', 'VAR') and node.t[0] not in ('_', '#')
424424

425425

426426
def common_type(a, b):

tests/api/test_check.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import unittest
5+
6+
from src.api import check
7+
from src import symbols
8+
9+
10+
class TestCheck(unittest.TestCase):
11+
""" Tests api.check
12+
"""
13+
def test_is_temporary_value_const_string(self):
14+
node = symbols.STRING("Hello world", 1)
15+
self.assertFalse(check.is_temporary_value(node))
16+
17+
def test_is_temporary_value_var(self):
18+
node = symbols.VAR("a", 1)
19+
self.assertFalse(check.is_temporary_value(node))
20+
21+
def test_is_temporary_value_param(self):
22+
node = symbols.PARAMDECL("a", 1)
23+
self.assertFalse(check.is_temporary_value(node))
24+
25+
def test_is_temporary_value_expr(self):
26+
child = symbols.VAR("a", 1)
27+
node = symbols.BINARY('PLUS', child, child, 1)
28+
self.assertTrue(check.is_temporary_value(node))

0 commit comments

Comments
 (0)