Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in LoginRefreshImpl and LoginStatusImpl #280

Closed
pupacicl opened this issue May 27, 2024 · 2 comments
Closed

Memory leak in LoginRefreshImpl and LoginStatusImpl #280

pupacicl opened this issue May 27, 2024 · 2 comments

Comments

@pupacicl
Copy link

pupacicl commented May 27, 2024

_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 pupacicl changed the title Memory leaks in LoginRefreshImpl and LoginStatusImpl Memory leak in LoginRefreshImpl and LoginStatusImpl May 27, 2024
@fogol
Copy link
Contributor

fogol commented May 29, 2024

@pupacicl Thank you for bringing this to our attention. It will be fixed in further releases.

@vlevendel
Copy link
Contributor

Fixed with version Real-Time-SDK-2.2.3.L1. Please reopen if there are additional concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants