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

FOGL-9354 Prevent Service Crash on Restart When Not Connected to OPC UA Server #50

Merged
merged 2 commits into from
Jan 2, 2025

Conversation

ashwini-k-pandey
Copy link
Contributor

No description provided.

{
subscriptionVariables.clear();
m_assetPathNames.clear();
m_client->Disconnect();
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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

Copy link
Contributor Author

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]>
@ashwini-k-pandey ashwini-k-pandey merged commit bcf2e82 into develop Jan 2, 2025
2 checks passed
@ashwini-k-pandey ashwini-k-pandey deleted the FOGL-9354 branch January 2, 2025 12:42
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

Successfully merging this pull request may close these issues.

4 participants