I know it's been a day, maybe you've changed your code.
The loop at line 34 makes p == NULL, so you can't free it at line 41.
I think you want to return p to x, and then free while x:
1 2 3 4 5 6 7 8 9 10
//@ line 40:
p = x;
while (x != NULL)
{
if (x->Test != NULL) // Which you should initialize these pointers to
free(x->Test);
p = x;
x = x->Next;
free(p);
}
Of course one thing to do is to let yourself have memory leaks until you can isolate the cause of the crash.