Fixed double free problem