From: Vedansh Bhartia Date: Thu, 6 Jul 2023 11:51:02 +0000 (+0530) Subject: rgw: Add check for whether RGWObjState was created in dbstore.cc X-Git-Tag: v19.0.0~916^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F52338%2Fhead;p=ceph.git rgw: Add check for whether RGWObjState was created in dbstore.cc Signed-off-by: Vedansh Bhartia --- diff --git a/src/rgw/driver/dbstore/common/dbstore.cc b/src/rgw/driver/dbstore/common/dbstore.cc index 3936368e6f7..0b8265a2bf3 100644 --- a/src/rgw/driver/dbstore/common/dbstore.cc +++ b/src/rgw/driver/dbstore/common/dbstore.cc @@ -1427,7 +1427,7 @@ int DB::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl, const DoutP if (r < 0) return r; - if (!astate->exists) { + if (!astate || !astate->exists) { return -ENOENT; } @@ -1451,17 +1451,15 @@ int DB::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl, const DoutP bool reading_from_head = (ofs < head_data_size); if (reading_from_head) { - if (astate) { // && astate->prefetch_data)? - if (!ofs && astate->data.length() >= len) { - bl = astate->data; - return bl.length(); - } + if (!ofs && astate->data.length() >= len) { + bl = astate->data; + return bl.length(); + } - if (ofs < astate->data.length()) { - unsigned copy_len = std::min((uint64_t)head_data_size - ofs, len); - astate->data.begin(ofs).copy(copy_len, bl); - return bl.length(); - } + if (ofs < astate->data.length()) { + unsigned copy_len = std::min((uint64_t)head_data_size - ofs, len); + astate->data.begin(ofs).copy(copy_len, bl); + return bl.length(); } }