Fixed a bug where freed pointer may be accessed.