Actually, to be more specific, it appears to happen immediately before the free(cur) would be executed...which seems even odder to me.
Likely you arewriting to already freed memory, outside this delete_from_list() function. The debug memory management facilities kick in upon the attempt to free() , catching the aforementioned error (-> runtime error message).
A minimal example that you could try out to see how it happens, would be along the lines of..
int main()
{
/* Allocate a node and initialize its examNumber to 1 */
struct node * p1 = alloc_node(1);
/* Allocate a node and initialize its examNumber to 2 */
struct node * p2 = alloc_node(2);
/* Make a list .. */
struct node * list = p1;
p1->next = p2;
p2->next = NULL;
/* free p1 .. */
list = delete_from_list(list, 1);
/* p1 still is accessible here, pointing to the freed memory,
* now write to that memory ..
*/
p1->next = NULL;
/* Try to free p2 .. */
list = delete_from_list(list, 2);
return 0;
}
For little more information on how this error gets caught, you might read Magic debug values .
[EDIT]
Also check that you are not trying to free anything twice/nor writing out-of-bounds.