Memory leak in licensed socket server code

Well, of course, the day after I released the 5.2.2 version of The Server Framework I get a bug report from a client using 5.2.1 listing a couple of memory leaks. One of them fixed in 5.2.2 and one not.

The leak that survived 5.2.2 is in CReadSequencingStreamSocketConnectionFilter::FilterSocketReleased() which currently looks like:

void CReadSequencingStreamSocketConnectionFilter::FilterSocketReleased(
   IIndexedOpaqueUserData &userData)
{
   delete userData.GetUserPointer(m_userDataIndex);
}

and which should look like:

void CReadSequencingStreamSocketConnectionFilter::FilterSocketReleased(
   IIndexedOpaqueUserData &userData)
{
   CInOrderBufferList *pBuffers = *reinterpret_cast<CInOrderBufferList *>(socket.GetUserPointer(m_userDataIndex));

   delete pBuffers;
}

Without the fix the wrong amount of memory is being released and the CInOrderBufferList destructor isn’t being called.

The reason that this bug survived the BoundsChecker session that found the other leak that was reported is that this piece of code doesn’t have a test harness and so was never called whilst the tool was running. So, guess what this morning’s first job is…

This fix will be included in the next release, I’m not sure when that will be and I’m not sure if it will finally be 5.3 or if I’ll slip a 5.2.3 release in there. The problem with the 5.3 release is that it includes some “big” changes and they’re not complete and I haven’t had time to work on them recently. Every so often someone needs some of the smaller changes and rather than allocate the time to fix the complete 5.3 release I move the changes to another point release… It works, but I’d really like to get the 5.3 buffer allocation alignment, multiple buffers in send and recv calls and general library shake up release done!