]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: avoid dereferencing an empty container during deep-copy 30177/head
authorJason Dillaman <dillaman@redhat.com>
Fri, 14 Jun 2019 17:34:24 +0000 (13:34 -0400)
committerNathan Cutler <ncutler@suse.com>
Thu, 5 Sep 2019 11:02:10 +0000 (13:02 +0200)
While updating the image copy progress, a 'while' loop will pop the
last item from the queue and then deference the empty queue.

Fixes: http://tracker.ceph.com/issues/40368
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 0f491cbb96ec55c68a627de71ed6ccd781a46dcc)

src/librbd/deep_copy/ImageCopyRequest.cc

index e3f742413fc21bfc5e164a4db3f0ebdbbb6026e3..171e25fb9013849e174ffcfbd0485686759a26e6 100644 (file)
@@ -229,8 +229,9 @@ void ImageCopyRequest<I>::handle_object_copy(uint64_t object_no, int r) {
       }
     } else {
       m_copied_objects.push(object_no);
-      while (!m_updating_progress && m_copied_objects.top() ==
-             (m_object_number ? *m_object_number + 1 : 0)) {
+      while (!m_updating_progress && !m_copied_objects.empty() &&
+             m_copied_objects.top() ==
+               (m_object_number ? *m_object_number + 1 : 0)) {
         m_object_number = m_copied_objects.top();
         m_copied_objects.pop();
         uint64_t progress_object_no = *m_object_number + 1;