Merge sort on list

I don’t know why my coding is giving an error on leetcode because the individual code for merging and finding the middle is working properly and I think I combined each and everything properly too.
Problem-https://leetcode.com/problems/sort-list/
Soln-https://ide.codingblocks.com/s/355698

let’s consider the case of 2 elments only
2->3
mid is null here
and you are not able to divide the list and hence stuck in infinite loop

for this at line no 16
change the statement to
while(fast and fast->next and fast->next->next){ add one exrra condition
to conter this situation

Modified Code

Thank you Sir, I understood this silly mistake of mine on why I was getting the error.