From: Kefu Chai Date: Sat, 18 Mar 2017 09:07:48 +0000 (+0800) Subject: os/bluestore: do not use nullptr to calc the size of bluestore_pextent_t X-Git-Tag: v12.0.1~14^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=79e91733a44d25ecaac78014dbfcdbbe47ce2567;p=ceph-ci.git os/bluestore: do not use nullptr to calc the size of bluestore_pextent_t see also #13889, otherwise this segfaults when compiled with -O0. Signed-off-by: Kefu Chai --- diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index a385a6acf2b..57f60afd1f9 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -165,9 +165,12 @@ struct denc_traits { static constexpr bool featured = false; static void bound_encode(const PExtentVector& v, size_t& p) { p += sizeof(uint32_t); - size_t per = 0; - denc(*(bluestore_pextent_t*)nullptr, per); - p += per * v.size(); + const auto size = v.size(); + if (size) { + size_t per = 0; + denc(v.front(), per); + p += per * size; + } } static void encode(const PExtentVector& v, bufferlist::contiguous_appender& p) {