]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw/dbstore: Fix null ptr reference
authorSoumya Koduri <skoduri@redhat.com>
Mon, 3 Jan 2022 07:26:31 +0000 (12:56 +0530)
committerSoumya Koduri <skoduri@redhat.com>
Thu, 13 Jan 2022 11:52:11 +0000 (17:22 +0530)
Initialize Object state once and use the same for all its
references. Also fixed a bug in SQLGetLC::prepare()

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
src/rgw/rgw_sal_dbstore.cc
src/rgw/rgw_sal_dbstore.h
src/rgw/store/dbstore/sqlite/sqliteDB.cc

index cddea7d8ab909a56ab9896635c83421df76124b8..677078404754885147a6bcd4b47c2131cfa6ea59 100644 (file)
@@ -565,9 +565,7 @@ namespace rgw::sal {
 
   int DBObject::get_obj_state(const DoutPrefixProvider* dpp, RGWObjectCtx* rctx, RGWObjState **state, optional_yield y, bool follow_olh)
   {
-    if (!*state) {
-      *state = new RGWObjState();
-    }
+    *state = &(this->state);
     DB::Object op_target(store->getDB(), get_bucket()->get_info(), get_obj());
     return op_target.get_obj_state(dpp, get_bucket()->get_info(), get_obj(), follow_olh, state);
   }
index 02d622a0682e219360f9137aff4bb23ba471cfdd..aaf3aa2304e284b4db7d36b7b55d2b1d9c82b535 100644 (file)
@@ -438,7 +438,7 @@ protected:
       /* XXX: to be removed. Till Dan's patch comes, a placeholder
        * for RGWObjState
        */
-      RGWObjState* state;
+      RGWObjState state;
 
     public:
       struct DBReadOp : public ReadOp {
@@ -475,13 +475,13 @@ protected:
       DBObject(DBStore *_st, const rgw_obj_key& _k)
         : Object(_k),
         store(_st),
-        acls() {
-        }
+        acls() {}
+
       DBObject(DBStore *_st, const rgw_obj_key& _k, Bucket* _b)
         : Object(_k, _b),
         store(_st),
-        acls() {
-        }
+        acls() {}
+
       DBObject(DBObject& _o) = default;
 
       virtual int delete_object(const DoutPrefixProvider* dpp,
index 67cd885adad2238b144ae544c2590941f68465ba..a7979b392d582adc2a018b7cf7d1802b850fec1d 100644 (file)
@@ -2669,10 +2669,10 @@ int SQLGetLCEntry::Bind(const DoutPrefixProvider *dpp, struct DBOpParams *params
   } else {
     pstmt = &stmt;
   }
-  SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_entry.index.c_str(), sdb);
+  SQL_BIND_INDEX(dpp, *pstmt, index, p_params.op.lc_entry.index.c_str(), sdb);
   SQL_BIND_TEXT(dpp, *pstmt, index, params->op.lc_entry.index.c_str(), sdb);
 
-  SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_entry.bucket_name.c_str(), sdb);
+  SQL_BIND_INDEX(dpp, *pstmt, index, p_params.op.lc_entry.bucket_name.c_str(), sdb);
   SQL_BIND_TEXT(dpp, *pstmt, index, params->op.lc_entry.entry.bucket.c_str(), sdb);
 
 out: