Without looking full code we can not guess where could be error. For current code it seems below code is faulty. Please add a log for null check
that = that->next
if(that ==null)
{
// std::cout<<"A null node found\n";
break;
}