Fix potential memory leak