desktop/qa/desktop_lib/test_desktop_lib.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
New commits: commit 98c0cefb18d8af7aa4732708ba0ae6be2e808d6f Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Jul 31 12:40:29 2019 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Jul 31 15:21:41 2019 +0200 desktop: fix UB in DesktopLOKTest::testCommentsCallbacksWriter() This was similar to the previous DesktopLOKTest::testWriterCommentInsertCursor() case. Also, go via the vtable in desktop/ so the callback caching there is not bypassed, which could be another source of dangling pointers. Change-Id: I78802b9014ece8f376ae3cf7c517b01c7d1076a0 Reviewed-on: https://gerrit.libreoffice.org/76737 Reviewed-by: Stephan Bergmann <sberg...@redhat.com> Tested-by: Jenkins diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 65c313cedfd0..6ad9c78edd13 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -1941,10 +1941,10 @@ void DesktopLOKTest::testWriterCommentInsertCursor() CPPUNIT_ASSERT(aView1.m_aOwnCursor.IsEmpty()); Scheduler::ProcessEventsToIdle(); - SfxLokHelper::setView(nView1); - SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); - SfxLokHelper::setView(nView2); - SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + pDocument->m_pDocumentClass->setView(pDocument, nView1); + pDocument->m_pDocumentClass->registerCallback(pDocument, nullptr, nullptr); + pDocument->m_pDocumentClass->setView(pDocument, nView2); + pDocument->m_pDocumentClass->registerCallback(pDocument, nullptr, nullptr); } #if HAVE_MORE_FONTS @@ -2141,9 +2141,11 @@ void DesktopLOKTest::testCommentsCallbacksWriter() ViewCallback aView2; LibLODocument_Impl* pDocument = loadDoc("comments.odt"); pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + int nView1 = pDocument->m_pDocumentClass->getView(pDocument); pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1); pDocument->m_pDocumentClass->createView(pDocument); pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + int nView2 = pDocument->m_pDocumentClass->getView(pDocument); pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView2); // Add a new comment @@ -2217,7 +2219,10 @@ void DesktopLOKTest::testCommentsCallbacksWriter() boost::property_tree::read_json(aStream, aTree); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), aTree.get_child("comments").size()); - pDocument->m_pDocumentClass->registerCallback(pDocument, nullptr, reinterpret_cast<void*>(1)); + pDocument->m_pDocumentClass->setView(pDocument, nView1); + pDocument->m_pDocumentClass->registerCallback(pDocument, nullptr, nullptr); + pDocument->m_pDocumentClass->setView(pDocument, nView2); + pDocument->m_pDocumentClass->registerCallback(pDocument, nullptr, nullptr); } void DesktopLOKTest::testRunMacro() commit d2355c7f27578ba04973ece3d2e58cfb60fb0714 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Jul 31 12:21:34 2019 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Jul 31 15:21:30 2019 +0200 desktop: fix UB in DesktopLOKTest::testWriterCommentInsertCursor() This was introduced in 70d3bbe11e56f12a339a5b8759b53a96b4fe84ab (sfx2: Enable sidebar on calc and writer, but not in impress, 2019-05-02). See <https://gerrit.libreoffice.org/76555> for an ubsan backtrace. Change-Id: Ib9bf9b12e78a29b2a165bb4ceda144c46f38f308 Reviewed-on: https://gerrit.libreoffice.org/76735 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Miklos Vajna <vmik...@collabora.com> diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 112f29f4c59e..65c313cedfd0 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -1912,9 +1912,11 @@ void DesktopLOKTest::testWriterCommentInsertCursor() ViewCallback aView2; LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + int nView1 = SfxLokHelper::getView(); pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1); pDocument->m_pDocumentClass->createView(pDocument); pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + int nView2 = SfxLokHelper::getView(); pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView2); pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'x', 0); pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 'x', 0); @@ -1939,7 +1941,10 @@ void DesktopLOKTest::testWriterCommentInsertCursor() CPPUNIT_ASSERT(aView1.m_aOwnCursor.IsEmpty()); Scheduler::ProcessEventsToIdle(); - pDocument->m_pDocumentClass->registerCallback(pDocument, nullptr, reinterpret_cast<void*>(1)); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } #if HAVE_MORE_FONTS _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits