]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
fastbmap_allocator_impl: avoid std::vector[] for oob index
authorSamuel Just <sjust@redhat.com>
Sat, 21 Dec 2019 02:04:47 +0000 (02:04 +0000)
committerSamuel Just <sjust@redhat.com>
Thu, 23 Jan 2020 00:03:14 +0000 (16:03 -0800)
This was relatively harmless as the pointer won't actually be
dereferenced, but it runs afoul of std::vector's bounds checks with
_GLIBCXX_ASSERTIONS enabled.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/os/bluestore/fastbmap_allocator_impl.cc

index 22e18c7141bf94ade57d38b10fcb6edc743e6ce6..441a185d5c72146339077bbb2fd6396b7a523a8c 100644 (file)
@@ -286,7 +286,7 @@ void AllocatorLevel01Loose::_mark_alloc_l0(int64_t l0_pos_start,
 
   int64_t pos = l0_pos_start;
   slot_t bits = (slot_t)1 << (l0_pos_start % d0);
-  slot_t* val_s = &l0[pos / d0];
+  slot_t* val_s = l0.data() + (pos / d0);
   int64_t pos_e = std::min(l0_pos_end, p2roundup<int64_t>(l0_pos_start + 1, d0));
   while (pos < pos_e) {
     (*val_s) &= ~bits;