fix memory leak in tempnam() usage