Fixed memory free bug