Howdy guys.

I have a loop that looks something like this:
Code:
while (1)
{
  accept(SFD...);
  CONNECTION NewConn();
  NewConn.ReadRequest();
}
When this code is run, ReadRequest is called, and then there is an error:
Debug Assertion Failed!
Program: C:\blahblah...
File: dbgheap.c
Line: 1011

Expression: _CrtIsValidHeapPointer(pUserData)

For more information blah...
dbgheap.c is not one of my files, so I expect its a microsoft one. I have tried not calling the ReadRequest function, and it works fine.

The error is not in the function, but comes at the end of the block before the loop starts again. I expect the problem is that after the ReadRequest function is called and the NewConn goes out of scope, something happens on the heap.

What should I be looking for in the ReadRequest function that could cause this sort of problem? I have no idea whats causing it nor do I fully understand the error, so any help would be greatly appreciated. Thanks