Seagment fault , please help. linked list sorting- merge sort


the problem was when mid will be returned as NULL
so i put that function in the same function and stored a prev pointer as temp to keep track of the previous node and worked upon it
if mid was NULL
mid->next gave a NULL pointer exception