double-free bug-fix