Open pupacicl opened 4 months ago
_rsslState is allocated on the heap but it is not deleted in destructor. Both LoginRefreshImpl and LoginStatusImpl do not seem to pass ownership to another object. Additionally operator= for both classes incorrectly copies the pointer.
Suggesting changes as follows:
diff --git a/Cpp-C/Ema/Src/Domain/Login/Impl/LoginRefreshImpl.cpp b/Cpp-C/Ema/Src/Domain/Login/Impl/LoginRefreshImpl.cpp index fcb527a95..51d315eeb 100644 --- a/Cpp-C/Ema/Src/Domain/Login/Impl/LoginRefreshImpl.cpp +++ b/Cpp-C/Ema/Src/Domain/Login/Impl/LoginRefreshImpl.cpp @@ -54,6 +54,12 @@ LoginRefreshImpl::~LoginRefreshImpl() delete _pElementList; _pElementList = 0; } + + if (_rsslState) + { + delete _rsslState; + _rsslState = 0; + } } LoginRefreshImpl& LoginRefreshImpl::clear() @@ -162,7 +168,6 @@ LoginRefreshImpl& LoginRefreshImpl::operator=(const LoginRefreshImpl& other) _authenticationErrorText = other._authenticationErrorText; _name = other._name; _nameType = other._nameType; - _rsslState = other._rsslState; _rsslState->streamState = other._state.getStreamState(); _rsslState->dataState = other._state.getDataState(); _rsslState->code = other._state.getCode(); diff --git a/Cpp-C/Ema/Src/Domain/Login/Impl/LoginStatusImpl.cpp b/Cpp-C/Ema/Src/Domain/Login/Impl/LoginStatusImpl.cpp index 999f16313..c17100732 100644 --- a/Cpp-C/Ema/Src/Domain/Login/Impl/LoginStatusImpl.cpp +++ b/Cpp-C/Ema/Src/Domain/Login/Impl/LoginStatusImpl.cpp @@ -53,6 +53,11 @@ LoginStatusImpl::~LoginStatusImpl() delete _pElementList; _pElementList = 0; } + if (_rsslState) + { + delete _rsslState; + _rsslState = 0; + } } LoginStatusImpl& LoginStatusImpl::clear() @@ -90,7 +95,6 @@ LoginStatusImpl& LoginStatusImpl::operator=(const LoginStatusImpl& other) _authenticationErrorText = other._authenticationErrorText; _name = other._name; _nameType = other._nameType; - _rsslState = other._rsslState; _stateText = other._stateText; _rsslState->streamState = other._state.getStreamState(); _rsslState->dataState = other._state.getDataState();
@pupacicl Thank you for bringing this to our attention. It will be fixed in further releases.
_rsslState is allocated on the heap but it is not deleted in destructor. Both LoginRefreshImpl and LoginStatusImpl do not seem to pass ownership to another object. Additionally operator= for both classes incorrectly copies the pointer.
Suggesting changes as follows: