Your while loop loops until p
is NULL, even if the node is found. Then you immediately dereference p
in the current->link=p->link
line, when p
is guaranteed to be NULL.
You need to break out of the while loop when you have found the right node. Putting && !found
into the while clause would do it.
Note that this is made harder to spot by the lack of indentation, I don't know if that is due to the cut-and-paste or if it is how you wrote it.