fix for a memory leak in an error case introduced by fix for double free