[core] fix memory corruption