logging: fix memory leak