fixed a memory leak in REPL
so that function calls won't result in crazy mallocation