The destructor deletes the pointer members:
WSSession::~WSSession( ) { delete m_navigationService; delete m_objectService; delete m_repositoryService; delete m_versioningService; }
but the assignment operator doesn't:
WSSession& WSSession::operator=( const WSSession& copy ) { if ( this != © ) { BaseSession::operator=( copy ); m_servicesUrls = copy.m_servicesUrls; m_navigationService = NULL; m_objectService = NULL; m_repositoryService = NULL; m_versioningService = NULL; m_responseFactory = copy.m_responseFactory; } return *this; }
That means if the pointer members are non-null when it is assigned to then everything leaks.
Thanks for the report. I'll try to check all objects and fix that, though I can't say when
Here's a patch to delete the existing members before setting the pointers to null. This only offers the Basic Exception-safety Guarantee, because if assigning the base subobject or the
m_serviceUrls
orm_responseFactory
members throws abad_alloc
exception then the object will be left in an inconsistent state (some members updated and some not) but it won't leak and won't leave any dangling pointers.This doesn't cause any test failures, but I don't think any of the tests actually use this assignment operator.
Last edit: Jonathan Wakely 2015-09-01
pushed in master. Thanks for the patch