Bug fix for a potential memory leak