Skip to content

Commit 79f0fb6

Browse files
Backport #97520 to 25.12: fix a possible use after free in StorageKafka2::activate()
1 parent b99117f commit 79f0fb6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Storages/Kafka/StorageKafka2.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ void StorageKafka2::partialShutdown()
210210
task->holder->deactivate();
211211
}
212212
is_active = false;
213+
/// Reset the active node holder while the old ZooKeeper session is still alive (even if expired).
214+
/// EphemeralNodeHolder stores a raw ZooKeeper reference, so resetting it here prevents a
215+
/// use-after-free: setZooKeeper() called afterwards may free the old session, and the holder's
216+
/// destructor would then access a dangling reference when checking zookeeper.expired().
217+
replica_is_active_node = nullptr;
213218
}
214219

215220
bool StorageKafka2::activate()

0 commit comments

Comments
 (0)