]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: avoid dereferencing an empty container during deep-copy 28559/head
authorJason Dillaman <dillaman@redhat.com>
Fri, 14 Jun 2019 17:34:24 +0000 (13:34 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 14 Jun 2019 17:34:24 +0000 (13:34 -0400)
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>
src/librbd/deep_copy/ImageCopyRequest.cc

index 2f0ff231bfa3e548363912a617a43f647c919d68..32a899b3c9324779b13422f45893bc958f5e1cb8 100644 (file)
@@ -143,8 +143,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;