Kaydet (Commit) 525a5ea3 authored tarafından Miklos Vajna's avatar Miklos Vajna

sw: avoid wrong and unnecessary downcast in SwDrawView::DeleteMarked()

/sw/source/core/draw/dview.cxx:967:39: runtime error: downcast of address 0x6060006d1cc0 which does not point to an object of type 'SwDrawContact'
0x6060006d1cc0: note: object is of type 'SwFlyDrawContact'
 1d 02 00 2e  b0 3e 06 87 15 7f 00 00  18 3f 06 87 15 7f 00 00  50 1c 28 00 50 61 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'SwFlyDrawContact'
    #0 0x7f157de946d8 in SwDrawView::DeleteMarked() /sw/source/core/draw/dview.cxx:967:39
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /sw/source/core/draw/dview.cxx:967:39 in

When executing testPasteListener in CppunitTest_sw_unowriter since
commit 2a054445 (sw paste listener:
expose pasted images as well, 2019-01-24), though that code was added
much earlier in commit 33141f99
(SwDrawView::DeleteMarked: delete textbox of shape as well, 2014-06-23),
just no testcase invoked it.

Change-Id: I22a384ab7cc4b3eb00198b28de294896c2d1e3bb
Reviewed-on: https://gerrit.libreoffice.org/66986Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst 906b5059
......@@ -964,8 +964,8 @@ void SwDrawView::DeleteMarked()
for (size_t i = 0; i < rMarkList.GetMarkCount(); ++i)
{
SdrObject *pObject = rMarkList.GetMark(i)->GetMarkedSdrObj();
SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(GetUserCall(pObject));
SwFrameFormat* pFormat = pDrawContact->GetFormat();
SwContact* pContact = GetUserCall(pObject);
SwFrameFormat* pFormat = pContact->GetFormat();
if (SwFrameFormat* pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(pFormat, RES_DRAWFRMFMT))
aTextBoxesToDelete.push_back(pTextBox);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment