aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorildar-khisam <ikhis@ydb.tech>2023-11-09 11:46:36 +0300
committerildar-khisam <ikhis@ydb.tech>2023-11-09 12:48:00 +0300
commit2bf93ed892f5bd35bc74f0e2f1b34768eab59a92 (patch)
tree7212889e69b8a418ec14215481a28c496432d24c
parent7695c63bbcdefb3b2dd6ca045d9a848c98154fc0 (diff)
downloadydb-2bf93ed892f5bd35bc74f0e2f1b34768eab59a92.tar.gz
fix rare null dereference
fix possible null dereference
-rw-r--r--ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/read_session.ipp21
1 files changed, 10 insertions, 11 deletions
diff --git a/ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/read_session.ipp b/ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/read_session.ipp
index d082856242..26abd73dd7 100644
--- a/ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/read_session.ipp
+++ b/ydb/public/sdk/cpp/client/ydb_persqueue_core/impl/read_session.ipp
@@ -243,12 +243,6 @@ void TSingleClusterReadSessionImpl<UseMigrationProtocol>::Start() {
template<bool UseMigrationProtocol>
bool TSingleClusterReadSessionImpl<UseMigrationProtocol>::Reconnect(const TPlainStatus& status) {
TDuration delay = TDuration::Zero();
- NGrpc::IQueueClientContextPtr delayContext = nullptr;
- NGrpc::IQueueClientContextPtr connectContext = ClientContext->CreateContext();
- NGrpc::IQueueClientContextPtr connectTimeoutContext = ClientContext->CreateContext();
- if (!connectContext || !connectTimeoutContext) {
- return false;
- }
// Previous operations contexts.
NGrpc::IQueueClientContextPtr prevConnectContext;
@@ -264,8 +258,18 @@ bool TSingleClusterReadSessionImpl<UseMigrationProtocol>::Reconnect(const TPlain
<< ". Description: " << IssuesSingleLineString(status.Issues));
}
+ NGrpc::IQueueClientContextPtr delayContext = nullptr;
+ NGrpc::IQueueClientContextPtr connectContext = nullptr;
+ NGrpc::IQueueClientContextPtr connectTimeoutContext = nullptr;
+
TDeferredActions<UseMigrationProtocol> deferred;
with_lock (Lock) {
+ connectContext = ClientContext->CreateContext();
+ connectTimeoutContext = ClientContext->CreateContext();
+ if (!connectContext || !connectTimeoutContext) {
+ return false;
+ }
+
if (Aborting) {
Cancel(connectContext);
Cancel(connectTimeoutContext);
@@ -1554,11 +1558,6 @@ void TSingleClusterReadSessionImpl<UseMigrationProtocol>::AbortImpl() {
Cancel(ConnectTimeoutContext);
Cancel(ConnectDelayContext);
- if (ClientContext) {
- ClientContext->Cancel();
- ClientContext.reset();
- }
-
if (Processor) {
Processor->Cancel();
}