]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs-mirror: fix a dangling pointer 39810/head
authorRonen Friedman <rfriedma@redhat.com>
Sun, 21 Feb 2021 12:21:06 +0000 (14:21 +0200)
committerVenky Shankar <vshankar@redhat.com>
Wed, 3 Mar 2021 13:58:49 +0000 (19:28 +0530)
stringify(snap_id) is ephemeral:

tools/cephfs_mirror/PeerReplayer.cc:916:62: warning: object backing the
pointer will be destroyed at the end of the full-expression

  snap_metadata snap_meta[] = {{PRIMARY_SNAP_ID_KEY.c_str(), stringify(snap_id).c_str()}};

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
(cherry picked from commit 717c5ddae44fe86747d1545f64901163b1619bf8)

src/tools/cephfs_mirror/PeerReplayer.cc

index 15bc3309f2cee630d40a131d91e8f0cb8c046d56..b3813584bc751bdda0c13fdf9f34a211a8ecbfca 100644 (file)
@@ -914,7 +914,8 @@ int PeerReplayer::synchronize(const std::string &dir_path, uint64_t snap_id,
     return r;
   }
 
-  snap_metadata snap_meta[] = {{PRIMARY_SNAP_ID_KEY.c_str(), stringify(snap_id).c_str()}};
+  auto snap_id_str{stringify(snap_id)};
+  snap_metadata snap_meta[] = {{PRIMARY_SNAP_ID_KEY.c_str(), snap_id_str.c_str()}};
   r = ceph_mksnap(m_remote_mount, dir_path.c_str(), snap_name.c_str(), 0755,
                   snap_meta, 1);
   if (r < 0) {