Check the stack is not null before cloning it.