Skip to content

Commit 4aa6ff9

Browse files
authored
Merge pull request ceph#61906 from nbalacha/wip-nbalacha-70075
librbd: fix a crash in get_rollback_snap_id
2 parents af9e68e + 7d75161 commit 4aa6ff9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/librbd/mirror/snapshot/Utils.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ bool get_rollback_snap_id(
3030
uint64_t *rollback_snap_id) {
3131

3232
for (; it != end; it++) {
33-
auto mirror_ns = std::get<cls::rbd::MirrorSnapshotNamespace>(
34-
it->second.snap_namespace);
35-
if (mirror_ns.state != cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY) {
33+
auto mirror_ns = std::get_if<cls::rbd::MirrorSnapshotNamespace>(
34+
&it->second.snap_namespace);
35+
if (mirror_ns == nullptr) {
36+
continue;
37+
}
38+
if (mirror_ns->state != cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY) {
3639
break;
3740
}
38-
if (mirror_ns.complete) {
41+
if (mirror_ns->complete) {
3942
break;
4043
}
4144
}

0 commit comments

Comments
 (0)