]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: avoid string_view to temporary in RGWBulkUploadOp 52159/head
authorCasey Bodley <cbodley@redhat.com>
Thu, 1 Sep 2022 14:50:46 +0000 (10:50 -0400)
committerCasey Bodley <cbodley@redhat.com>
Thu, 22 Jun 2023 15:40:21 +0000 (11:40 -0400)
the `else` block below constructs a temporary std::string that destructs
at the end of the statement, leaving `filename` as a dangling view:
```
filename = file_prefix + std::string(header->get_filename());
```
store a copy of the `std::string` instead

Fixes: https://tracker.ceph.com/issues/57326
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit e9c2ac02f1f59714677e3e1b984367df3c0ec166)

src/rgw/rgw_op.cc

index 224f8d1e7f7186a51592b73e85e4ef13ec3894cb..e2d74d9cedd7257534e3e250dd4883f25e48578f 100644 (file)
@@ -7928,7 +7928,7 @@ void RGWBulkUploadOp::execute(optional_yield y)
         case rgw::tar::FileType::NORMAL_FILE: {
           ldpp_dout(this, 2) << "handling regular file" << dendl;
 
-          std::string_view filename;
+          std::string filename;
          if (bucket_path.empty())
            filename = header->get_filename();
          else