Fix invalid malloc on slice

This commit is contained in:
Nathan Braswell
2017-01-23 23:00:26 -05:00
parent 3a7f73b711
commit f0a657e80f

View File

@@ -422,10 +422,14 @@ obj c_generator (Object) {
var cond = code_triple(";") var cond = code_triple(";")
if (node->for_loop.condition) if (node->for_loop.condition)
cond = generate(node->for_loop.condition, enclosing_object, enclosing_func, false) cond = generate(node->for_loop.condition, enclosing_object, enclosing_func, false)
var update = code_triple() var update = string()
if (node->for_loop.update) if (node->for_loop.update) {
update = generate(node->for_loop.update, enclosing_object, enclosing_func, false) update = generate(node->for_loop.update, enclosing_object, enclosing_func, false).one_string()
var to_ret = string("for (") + init.one_string() + cond.one_string() + "; " + update.one_string().slice(0,-2) + ")\n" + if (update.length() < 2)
error("update less than 2! Likely legal, but need easy compiler mod here")
update = update.slice(0,-2)
}
var to_ret = string("for (") + init.one_string() + cond.one_string() + "; " + update + ")\n" +
generate(node->for_loop.body, enclosing_object, enclosing_func, false).one_string() generate(node->for_loop.body, enclosing_object, enclosing_func, false).one_string()
return code_triple(to_ret) return code_triple(to_ret)
} }