svx/source/svdraw/svdpntv.cxx |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit de1c0ccc3766b4a9367d16a972adc04ef011a536
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Thu Feb 10 10:25:52 2022 -0400
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Fri Feb 11 12:46:26 2022 +0100

    svx: fix dynamic cast SdrView
    
    Jan 19 13:48:41 ip-172-31-35-149 coolwsd[23647]: SUMMARY: 
UndefinedBehaviorSanitizer: undefined-behavior 
/home/collabora/online-buildscripts/staging/builddir/libreoffice/svx/source/sdr/contact/objectcontactofpageview.cxx:353:57
 in
    Jan 19 13:48:41 ip-172-31-35-149 coolwsd[23647]: 
/home/collabora/online-buildscripts/staging/builddir/libreoffice/include/svx/svdview.hxx:235:65:
 runtime error: member access within address 0x61c000489880 which does not 
point to an object of type 'SdrView'
    Jan 19 13:48:41 ip-172-31-35-149 coolwsd[23647]: 0x61c000489880: note: 
object is of type 'SdrPaintView'
    Jan 19 13:48:41 ip-172-31-35-149 coolwsd[23647]:  7c 04 80 3b  90 58 b9 3d 
60 7f 00 00  30 51 96 0a 20 60 00 00  38 51 96 0a 20 60 00 00  38 51 96 0a
    Jan 19 13:48:41 ip-172-31-35-149 coolwsd[23647]:               
^~~~~~~~~~~~~~~~~~~~~~~
    Jan 19 13:48:41 ip-172-31-35-149 coolwsd[23647]:               vptr for 
'SdrPaintView'
    
    Change-Id: Ifc9177902ac834d400d6bf9f72b94e82f544b348
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129791
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Henry Castro <hcas...@collabora.com>

diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx
index 5ab5b150d175..0135120e577a 100644
--- a/svx/source/svdraw/svdpntv.cxx
+++ b/svx/source/svdraw/svdpntv.cxx
@@ -365,8 +365,11 @@ SdrPageView* SdrPaintView::ShowSdrPage(SdrPage* pPage)
             mpPageView.reset();
         }
 
-        mpPageView.reset(new SdrPageView(pPage, *static_cast<SdrView*>(this)));
-        mpPageView->Show();
+        if (SdrView *pView = dynamic_cast<SdrView*>(this))
+        {
+            mpPageView.reset(new SdrPageView(pPage, *pView));
+            mpPageView->Show();
+        }
     }
 
     return mpPageView.get();

Reply via email to