From c1704f2e6be8b0582bffc54e0adc505e0876fca5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 21 Jul 2017 23:31:55 -0400 Subject: [PATCH] mon: do not dereference empty mgr_commands This may be empty before the initial quorum commits the static command list. Signed-off-by: Sage Weil --- src/mon/Monitor.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 9ec308d7832a0..7595018df10ed 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -3013,8 +3013,10 @@ void Monitor::handle_command(MonOpRequestRef op) const MonCommand *leader_cmd; const auto& mgr_cmds = mgrmon()->get_command_descs(); - const MonCommand *mgr_cmd = _get_moncommand(prefix, &mgr_cmds.at(0), - mgr_cmds.size()); + const MonCommand *mgr_cmd = nullptr; + if (!mgr_cmds.empty()) { + mgr_cmd = _get_moncommand(prefix, &mgr_cmds.at(0), mgr_cmds.size()); + } leader_cmd = _get_moncommand(prefix, // the boost underlying this isn't const for some reason const_cast(leader_supported_mon_commands), -- 2.39.5