如何解决此Valgrind错误:大小为8的无效读取

I get the following error from valgrind whenever I use A function I made called getNext

Invalid read of size 8
==26278==    at 0x401341: getNext (election_element.c:153)
==26278==    by 0x400D3F: electionRemoveAreas (election.c:261)
==26278==    by 0x4013FB: main (tests.c:27)

这是我的功能:

Election_element getNext(Election_element element)
{
  return element->next;
}

这是功能lectionRemoveArea的一部分

Election_element area=election->area;
  while (area)
  {
    if(should_delete_area(getElementId(area)))
    {
     destroyVotes(getVotes(area));
     election->area=removeElement(election->area,getElementId(area));
    }
   area=getNext(area);
  }
评论