Fixed invalid use of freed memory.