Add check for NULL list head in makeEmpty

This commit is contained in:
Shaun Reed 2020-04-26 18:12:09 -04:00
parent ac46149191
commit 58d77e09cd
2 changed files with 4 additions and 2 deletions

Binary file not shown.

View File

@ -130,8 +130,10 @@ bool SingleList::replace(int val, int key)
*/
void SingleList::makeEmpty()
{
Node *nextNode = head->next;
Node *temp;
Node *nextNode, *temp;
if (head == NULL) return;
nextNode = head->next;
delete head;
head = NULL;
while(nextNode != NULL) {