Fixed a issue for using heap after free