From: liu shi Date: Fri, 14 May 2021 07:51:01 +0000 (-0400) Subject: cpu_profiler: fix asok command crash X-Git-Tag: v16.2.14~3^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d83d472f63616c55e7dee1013bde77de8167cf1c;p=ceph.git cpu_profiler: fix asok command crash fixes: https://tracker.ceph.com/issues/50814 Signed-off-by: liu shi (cherry picked from commit be7303aafe34ae470d2fd74440c3a8d51fcfa3ff) --- diff --git a/src/perfglue/cpu_profiler.cc b/src/perfglue/cpu_profiler.cc index ea1be7e95959..81f2ccf8c9f6 100644 --- a/src/perfglue/cpu_profiler.cc +++ b/src/perfglue/cpu_profiler.cc @@ -22,7 +22,7 @@ void cpu_profiler_handle_command(const std::vector &cmd, std::ostream& out) { - if (cmd[1] == "status") { + if (cmd.size() == 1 && cmd[0] == "status") { ProfilerState st; ProfilerGetCurrentState(&st); out << "cpu_profiler " << (st.enabled ? "enabled":"not enabled") @@ -30,7 +30,7 @@ void cpu_profiler_handle_command(const std::vector &cmd, << " profile_name " << st.profile_name << " samples " << st.samples_gathered; } - else if (cmd[1] == "flush") { + else if (cmd.size() == 1 && cmd[0] == "flush") { ProfilerFlush(); out << "cpu_profiler: flushed"; }