Skip to content

Commit

Permalink
[C++] Archive Client AsyncConnect::poll: Avoid proceeding to step 1 u…
Browse files Browse the repository at this point in the history
…ntil m_subscription is non-null (#1196)

* Avoid proceeding to step 1 until m_subscription is non-null

findSubscription() may return a null pointer that is used unchecked in step 1,

* Avoid null pointer access in timeout message
  • Loading branch information
vaci authored Jul 9, 2021
1 parent 7f66a89 commit 38569ed
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions aeron-archive/src/main/cpp/client/AeronArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ std::shared_ptr<AeronArchive> AeronArchive::AsyncConnect::poll()
throw TimeoutException(
"Archive connect timeout: step=" + std::to_string(m_step) +
(m_step < 2 ?
" publication.uri=" + m_publication->channel() :
" subscription.uri=" + m_subscription->channel()),
" publication.uri=" + (m_publication ? m_publication->channel() : "<undiscovered>") :
" subscription.uri=" + (m_subscription ? m_subscription->channel() : "<undiscovered>")),
SOURCEINFO);
}

Expand Down Expand Up @@ -76,7 +76,7 @@ std::shared_ptr<AeronArchive> AeronArchive::AsyncConnect::poll()
m_step = 1;
}

if (1 == m_step)
if (1 == m_step && m_subscription)
{
std::string controlResponseChannel = m_subscription->tryResolveChannelEndpointPort();
if (controlResponseChannel.empty())
Expand Down

0 comments on commit 38569ed

Please sign in to comment.