In your insert function, check the pointer you retrieve from find
:
if (loc != NULL) {
// insert pointer into non-empty list
The find
function and the pointer you retrieve from it is really where the problem lies, because you do not check whether it has returned a valid pointer.