From 7a296fa017e2518b7ec22730197925c40174ffe2 Mon Sep 17 00:00:00 2001 From: songbaisen Date: Wed, 27 Jul 2016 10:01:31 +0800 Subject: [PATCH] tools: fix the core dump when get the crushmap do not exist Signed-off-by:song baisen --- src/tools/ceph_monstore_tool.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index f9b4696c527d..347fb9e84d37 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -697,9 +697,11 @@ int main(int argc, char **argv) { } else if (map_type == "crushmap") { bufferlist tmp; r = st.get("osdmap", st.combine_strings("full", v), tmp); - OSDMap osdmap; - osdmap.decode(tmp); - osdmap.crush->encode(bl); + if (r >= 0) { + OSDMap osdmap; + osdmap.decode(tmp); + osdmap.crush->encode(bl); + } } else { r = st.get(map_type, v, bl); } -- 2.47.3