Commit e7bb0443 authored by Damien George's avatar Damien George
Browse files

py: Properly free string parse-node; add assertion to gc_free.

parent dd4f4530
...@@ -484,7 +484,11 @@ void gc_free(void *ptr_in) { ...@@ -484,7 +484,11 @@ void gc_free(void *ptr_in) {
#if EXTENSIVE_HEAP_PROFILING #if EXTENSIVE_HEAP_PROFILING
gc_dump_alloc_table(); gc_dump_alloc_table();
#endif #endif
} else {
assert(!"bad free");
} }
} else if (ptr_in != NULL) {
assert(!"bad free");
} }
} }
......
...@@ -180,17 +180,17 @@ void mp_parse_node_free(mp_parse_node_t pn) { ...@@ -180,17 +180,17 @@ void mp_parse_node_free(mp_parse_node_t pn) {
mp_uint_t rule_id = MP_PARSE_NODE_STRUCT_KIND(pns); mp_uint_t rule_id = MP_PARSE_NODE_STRUCT_KIND(pns);
if (rule_id == RULE_string) { if (rule_id == RULE_string) {
m_del(char, (char*)pns->nodes[0], (mp_uint_t)pns->nodes[1]); m_del(char, (char*)pns->nodes[0], (mp_uint_t)pns->nodes[1]);
return; } else {
} bool adjust = ADD_BLANK_NODE(rule_id);
bool adjust = ADD_BLANK_NODE(rule_id); if (adjust) {
if (adjust) { n--;
n--; }
} for (mp_uint_t i = 0; i < n; i++) {
for (mp_uint_t i = 0; i < n; i++) { mp_parse_node_free(pns->nodes[i]);
mp_parse_node_free(pns->nodes[i]); }
} if (adjust) {
if (adjust) { n++;
n++; }
} }
m_del_var(mp_parse_node_struct_t, mp_parse_node_t, n, pns); m_del_var(mp_parse_node_struct_t, mp_parse_node_t, n, pns);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment