summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-07-31 12:40:29 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-07-31 15:21:41 +0200
commit98c0cefb18d8af7aa4732708ba0ae6be2e808d6f (patch)
tree163660db7b6cead19e213b21e537a3a5b412ea4f /desktop
parentd2355c7f27578ba04973ece3d2e58cfb60fb0714 (diff)
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 <sbergman@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx15
1 files changed, 10 insertions, 5 deletions
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()