tcl: fix potential memory leaks