From: Radoslaw Zarzynski Date: Tue, 18 Sep 2018 20:03:06 +0000 (+0200) Subject: common: bufferlist can contain 0-length bptrs. X-Git-Tag: v14.1.0~222^2~9 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c7a53ecfbceebd16025ad1368e0687e1c6185103;p=ceph-ci.git common: bufferlist can contain 0-length bptrs. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 078d4132168..c3bce4c0ee0 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -734,14 +734,8 @@ static ceph::spinlock debug_lock; // << " (p_off " << p_off << " in " << p->length() << ")" // << std::endl; - p_off += o; - - if (!o) { - return; - } - while (p_off > 0) { - if (p == ls->end()) - throw end_of_buffer(); + p_off +=o; + while (p != ls->end()) { if (p_off >= p->length()) { // skip this buffer p_off -= p->length(); @@ -751,6 +745,9 @@ static ceph::spinlock debug_lock; break; } } + if (p == ls->end() && p_off) { + throw end_of_buffer(); + } off += o; } @@ -806,7 +803,6 @@ static ceph::spinlock debug_lock; while (len > 0) { if (p == ls->end()) throw end_of_buffer(); - ceph_assert(p->length() > 0); unsigned howmuch = p->length() - p_off; if (len < howmuch) howmuch = len; @@ -832,7 +828,6 @@ static ceph::spinlock debug_lock; } if (p == ls->end()) throw end_of_buffer(); - ceph_assert(p->length() > 0); dest = create(len); copy(len, dest.c_str()); } @@ -845,7 +840,6 @@ static ceph::spinlock debug_lock; } if (p == ls->end()) throw end_of_buffer(); - ceph_assert(p->length() > 0); unsigned howmuch = p->length() - p_off; if (howmuch < len) { dest = create(len); @@ -903,7 +897,6 @@ static ceph::spinlock debug_lock; while (1) { if (p == ls->end()) return; - ceph_assert(p->length() > 0); unsigned howmuch = p->length() - p_off; const char *c_str = p->c_str(); @@ -1048,7 +1041,6 @@ static ceph::spinlock debug_lock; ++b; } } - ceph_assert(b == std::cend(other._buffers)); return true; }