fix 3 possible memleaks if io->redirect