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() void SingleList::makeEmpty()
{ {
Node *nextNode = head->next; Node *nextNode, *temp;
Node *temp;
if (head == NULL) return;
nextNode = head->next;
delete head; delete head;
head = NULL; head = NULL;
while(nextNode != NULL) { while(nextNode != NULL) {