]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: avoid dereferencing an empty container during deep-copy 28577/head
authorJason Dillaman <dillaman@redhat.com>
Fri, 14 Jun 2019 17:34:24 +0000 (13:34 -0400)
committerJason Dillaman <dillaman@redhat.com>
Sat, 15 Jun 2019 12:07:52 +0000 (08:07 -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>
(cherry picked from commit 0f491cbb96ec55c68a627de71ed6ccd781a46dcc)

src/librbd/deep_copy/ImageCopyRequest.cc

index bcf9970bf589d251389afb38ceecb39c2578110c..e446c3a5869a1651313bcd0d92019a91610ae086 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;