-1

I would like to delete a BST, my program works but, I don't know way, AddressSanitizer find an error.

void clear_maxlist(max_list* position){
  if(position == NULL)
    return;
  clear_maxlist(((position)->left));
  clear_maxlist(((position)->right));
  free(position);
}

I get this error:

==6643==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x0000004039c1 bp 0x7ffdc2a35f20 sp 0x7ffdc2a35f10 T0)
Bob Rob
  • 164
  • 2
  • 10

1 Answers1

0

You must have one node in your tree whose left or right pointer should be NULL, but it is not. So, there must be an error in the code that constructs the tree.

RobertBaron
  • 2,817
  • 1
  • 12
  • 19