From 631ed4f33d99fcbe348f4424b5d5e65aa0a549d8 Mon Sep 17 00:00:00 2001 From: Vedansh Bhartia Date: Thu, 6 Jul 2023 17:21:02 +0530 Subject: [PATCH] rgw: Add check for whether RGWObjState was created in dbstore.cc Signed-off-by: Vedansh Bhartia --- src/rgw/driver/dbstore/common/dbstore.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/rgw/driver/dbstore/common/dbstore.cc b/src/rgw/driver/dbstore/common/dbstore.cc index 3936368e6f7f8..0b8265a2bf34e 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(); } } -- 2.39.5