]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: do not dereference empty mgr_commands 16501/head
authorSage Weil <sage@redhat.com>
Sat, 22 Jul 2017 03:31:55 +0000 (23:31 -0400)
committerSage Weil <sage@redhat.com>
Sat, 22 Jul 2017 03:32:05 +0000 (23:32 -0400)
This may be empty before the initial quorum commits the static command
list.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/Monitor.cc

index 9ec308d7832a06c744082785b104f2251a73a310..7595018df10edabb3c4a9cef1c619ea2536aef7b 100644 (file)
@@ -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<MonCommand*>(leader_supported_mon_commands),