Fix bug of free memory