-
Notifications
You must be signed in to change notification settings - Fork 2
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
FOGL-9354 Prevent Service Crash on Restart When Not Connected to OPC UA Server #50
Conversation
Signed-off-by: Ashwini Kumar Pandey <[email protected]>
{ | ||
subscriptionVariables.clear(); | ||
m_assetPathNames.clear(); | ||
m_client->Disconnect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this inside an if (m_client) test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following code is executed under the m_connected
flag, which guarantees that m_client
is never null at this point. However, it’s important to note that m_client
(of type UaClient
) is not exception-safe. The Disconnect()
method can throw exceptions, and since Disconnect()
is called in delete m_client
, this raises a risk of memory leaks if an exception occurs during disconnection.
Currently, our implementation ensures that the process exits after invoking OPCUA::stop()
, which protects us from memory leaks under normal circumstances.
If you agree i would like to add this finding as comments here ..
} | ||
if (m_client) | ||
{ | ||
delete m_client; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set m_client back to NULL so that other tests will fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: Ashwini Kumar Pandey <[email protected]>
No description provided.