[Libreoffice-commits] core.git: sw/source

Stephan Bergmann sbergman at redhat.com
Wed Apr 6 10:26:08 UTC 2016


 sw/source/uibase/uiview/pview.cxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 30e24a0a29c3f5237babd06ddf0855ecf38054a0
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Apr 6 12:24:06 2016 +0200

    Avoid bad downcast from SwViewShell to SwEditShell
    
    At least the checkTitleNumbers(complex.XTitle.CheckXTitle) in
    JunitTest_framework_complex triggered the UBSan failure
    
    > sw/source/uibase/uiview/pview.cxx:1139:25: runtime error: downcast of address 0x61300047e500 which does not point to an object of type 'SwEditShell'
    > 0x61300047e500: note: object is of type 'SwViewShell'
    >  d3 03 80 0d  10 f6 8e e0 fa 2a 00 00  80 b2 1b 00 90 61 00 00  80 b2 1b 00 90 61 00 00  00 00 00 00
    >               ^~~~~~~~~~~~~~~~~~~~~~~
    >               vptr for 'SwViewShell'
    >     #0 0x2afadd5b9594 in SwPagePreview::Init() sw/source/uibase/uiview/pview.cxx:1139:25
    >     #1 0x2afadd5c0e29 in SwPagePreview::SwPagePreview(SfxViewFrame*, SfxViewShell*) sw/source/uibase/uiview/pview.cxx:1251:5
    >     #2 0x2afadd58c7a5 in SwPagePreview::CreateInstance(SfxViewFrame*, SfxViewShell*) sw/source/uibase/uiview/pview.cxx:85:1
    >     #3 0x2afa4a476c8c in SfxViewFactory::CreateInstance(SfxViewFrame*, SfxViewShell*) sfx2/source/view/viewfac.cxx:28:12
    >     #4 0x2afa49b677a5 in SfxBaseModel::createViewController(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) sfx2/source/doc/sfxbasemodel.cxx:4255:32
    >     #5 0x2afa49b6ac45 in non-virtual thunk to SfxBaseModel::createViewController(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) sfx2/source/doc/sfxbasemodel.cxx:4217:57
    >     #6 0x2afa4a38bd08 in (anonymous namespace)::SfxFrameLoader_Impl::impl_createDocumentView(com::sun::star::uno::Reference<com::sun::star::frame::XModel2> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, comphelper::NamedValueCollection const&, rtl::OUString const&) sfx2/source/view/frmload.cxx:600:50
    >     #7 0x2afa4a37f627 in (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) sfx2/source/view/frmload.cxx:728:13
    >     #8 0x2afac3723d1a in framework::LoadEnv::impl_loadContent() framework/source/loadenv/loadenv.cxx:1117:24
    >     #9 0x2afac3707b02 in framework::LoadEnv::startLoading() framework/source/loadenv/loadenv.cxx:379:20
    >     #10 0x2afac37007d5 in framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) framework/source/loadenv/loadenv.cxx:165:9
    >     #11 0x2afac396848d in (anonymous namespace)::Frame::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) framework/source/services/frame.cxx:608:12
    >     #12 0x2afac39a369a in non-virtual thunk to (anonymous namespace)::Frame::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) framework/source/services/frame.cxx:587:62
    >     #13 0x2afa4a4cdd1a in SfxViewFrame::LoadViewIntoFrame_Impl(SfxObjectShell const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, unsigned short, bool) sfx2/source/view/viewfrm.cxx:1897:5
    >     #14 0x2afa4a501df3 in SfxViewFrame::SwitchToViewShell_Impl(unsigned short, bool) sfx2/source/view/viewfrm.cxx:2096:32
    >     #15 0x2afa4a4a7491 in SfxViewFrame::ExecView_Impl(SfxRequest&) sfx2/source/view/viewfrm.cxx:2181:29
    >     #16 0x2afa4a4a5d16 in SfxStubSfxViewFrameExecView_Impl(SfxShell*, SfxRequest&) workdir/SdiTarget/sfx2/sdi/sfxslots.hxx:709:1
    >     #17 0x2afa483dfe06 in SfxShell::CallExec(void (*)(SfxShell*, SfxRequest&), SfxRequest&) include/sfx2/shell.hxx:204:35
    >     #18 0x2afa48392c56 in SfxDispatcher::Call_Impl(SfxShell&, SfxSlot const&, SfxRequest&, bool) sfx2/source/control/dispatch.cxx:262:13
    >     #19 0x2afa483bf830 in SfxDispatcher::PostMsgHandler(SfxRequest*) sfx2/source/control/dispatch.cxx:1085:17
    >     #20 0x2afa48398545 in SfxDispatcher::LinkStubPostMsgHandler(void*, SfxRequest*) sfx2/source/control/dispatch.cxx:1065:1
    >     #21 0x2afa49d320a7 in Link<SfxRequest*, void>::Call(SfxRequest*) const include/tools/link.hxx:84:45
    >     #22 0x2afa49d31b50 in SfxHintPoster::DoEvent_Impl(void*) sfx2/source/notify/hintpost.cxx:44:5
    >     #23 0x2afa49d319e5 in SfxHintPoster::LinkStubDoEvent_Impl(void*, void*) sfx2/source/notify/hintpost.cxx:42:1
    >     #24 0x2afa69f03327 in Link<void*, void>::Call(void*) const include/tools/link.hxx:84:45
    >     #25 0x2afa69eec39f in ImplHandleUserEvent(ImplSVEvent*) vcl/source/window/winproc.cxx:1959:13
    >     #26 0x2afa69ed7183 in ImplWindowFrameProc(vcl::Window*, unsigned short, void const*) vcl/source/window/winproc.cxx:2527:13
    >     #27 0x2afa6cf9a0f9 in SalFrame::CallCallback(unsigned short, void const*) const vcl/inc/salframe.hxx:273:33
    >     #28 0x2afa6cff0a85 in SvpSalInstance::DoYield(bool, bool, unsigned long) vcl/headless/svpinst.cxx:293:17
    >     #29 0x2afa6c484a64 in ImplYield(bool, bool, unsigned long) vcl/source/app/svapp.cxx:509:9
    >     #30 0x2afa6c45ed83 in Application::Yield() vcl/source/app/svapp.cxx:553:5
    >     #31 0x2afa6c45eb1a in Application::Execute() vcl/source/app/svapp.cxx:473:9
    >     #32 0x2afa38280294 in desktop::Desktop::DoExecute() desktop/source/app/app.cxx:1322:5
    >     #33 0x2afa3828ada3 in desktop::Desktop::Main() desktop/source/app/app.cxx:1647:17
    >     #34 0x2afa6c4de08e in ImplSVMain() vcl/source/app/svmain.cxx:172:19
    >     #35 0x2afa6c4eb776 in SVMain() vcl/source/app/svmain.cxx:210:16
    >     #36 0x2afa384c5d01 in soffice_main desktop/source/app/sofficemain.cxx:135:12
    >     #37 0x4f0f0c in sal_main desktop/source/app/main.c:48:15
    >     #38 0x4f0ee6 in main desktop/source/app/main.c:47:1
    >     #39 0x2afa39e4c57f in __libc_start_main (/lib64/libc.so.6+0x2057f)
    >     #40 0x418f48 in _start (instdir/program/soffice.bin+0x418f48)
    
    Change-Id: I4a32bcf4dea4616d4726c28ba01adba9083ad1c6

diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx
index 47136c1..20fff29 100644
--- a/sw/source/uibase/uiview/pview.cxx
+++ b/sw/source/uibase/uiview/pview.cxx
@@ -1136,8 +1136,8 @@ void SwPagePreview::Init()
     // Update the fields
     // ATTENTION: Do cast the EditShell up, to use the SS.
     //            At the methodes the current shell will be queried!
-    SwEditShell* pESh = static_cast<SwEditShell*>(GetViewShell());
-    bool bIsModified = pESh->IsModified();
+    SwEditShell* pESh = dynamic_cast<SwEditShell*>(GetViewShell());
+    bool bIsModified = pESh != nullptr && pESh->IsModified();
 
     SwViewOption aOpt( *pPrefs );
     aOpt.SetPagePreview(true);
@@ -1172,7 +1172,7 @@ void SwPagePreview::Init()
     GetViewShell()->CalcLayout();
     DocSzChgd( GetViewShell()->GetDocSize() );
 
-    if( !bIsModified )
+    if( !bIsModified && pESh != nullptr )
         pESh->ResetModified();
 }
 


More information about the Libreoffice-commits mailing list