From 1ed62076a35deeffea3dac79f16be32136f4fc22 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 23 Mar 2017 08:21:39 -0500 Subject: [PATCH] os/bluestore: avoid nullptr in bluestore_extent_ref_map_t::bound_encode Signed-off-by: Sage Weil --- src/os/bluestore/bluestore_types.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index 57f60afd1f9..ec0967d296f 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -224,10 +224,12 @@ struct bluestore_extent_ref_map_t { void bound_encode(size_t& p) const { denc_varint((uint32_t)0, p); - size_t elem_size = 0; - denc_varint_lowz((uint32_t)0, p); - ((const record_t*)nullptr)->bound_encode(elem_size); - p += elem_size * ref_map.size(); + if (!ref_map.empty()) { + size_t elem_size = 0; + denc_varint_lowz((uint64_t)0, elem_size); + ref_map.begin()->second.bound_encode(elem_size); + p += elem_size * ref_map.size(); + } } void encode(bufferlist::contiguous_appender& p) const { uint32_t n = ref_map.size();