sw: fix undefined casts of SwTxtInputFld

Desktop / LibreOffice - Michael Stahl [redhat.com] - 22 October 2014 17:04 UTC

... as reported by sberg via UBSan in CppunitTest_sw_mailmerge:

> sw/source/core/txtnode/thints.cxx:3207:38: runtime error: downcast of address 0x000003cadcb0 which does not point to an object of type 'SwTxtAttrNesting' > 0x000003cadcb0: note: object is of type 'SwTxtInputFld' > #0 in SwpHints::TryInsertHint(SwTxtAttr*, SwTxtNode&, unsigned short) sw/source/core/txtnode/thints.cxx:3207:13 > #1 in SwTxtNode::InsertHint(SwTxtAttr*, unsigned short) sw/source/core/txtnode/thints.cxx:1583:25 > #2 in SwTxtNode::SetAttr(SfxItemSet const&, int, int, unsigned short) sw/source/core/txtnode/thints.cxx:1943:39 > #3 in SwRegHistory::InsertItems(SfxItemSet const&, int, int, unsigned short) sw/source/core/undo/rolbck.cxx:1390:28 > #4 in (anonymous namespace)::lcl_InsAttr(SwDoc*, SwPaM const&, SfxItemSet const&, unsigned short, SwUndoAttr*, bool) sw/source/core/doc/DocumentContentOperationsManager.cxx:1169:28 > #5 in sw::DocumentContentOperationsManager::InsertPoolItem(SwPaM const&, SfxPoolItem const&, unsigned short, bool) sw/source/core/doc/DocumentContentOperationsManager.cxx:3041:23 > #6 in SwXTextField::attach(com::sun::star::uno::Reference const&) sw/source/core/unocore/unofield.cxx:1966:13 > #7 in non-virtual thunk to SwXTextField::attach(com::sun::star::uno::Reference const&) sw/source/core/unocore/unofield.cxx:2061:1

The SwTxtInputFld is unusual because it's both a field and has a range; let's try to use virtual inheritance to inherit both from SwTxtFld and SwTxtAttrNesting. Sadly requires dynamic_cast everywhere.

72f368f sw: fix undefined casts of SwTxtInputFld
sw/inc/txatbase.hxx | 21 ++++++-
sw/inc/txtatr.hxx | 8 ---
sw/inc/txtfld.hxx | 9 ++-
sw/source/core/access/accpara.cxx | 3 +-
sw/source/core/crsr/crstrvl.cxx | 4 +-
sw/source/core/crsr/findtxt.cxx | 5 +-
sw/source/core/docnode/nodes.cxx | 4 +-
sw/source/core/fields/cellfml.cxx | 2 +-
sw/source/core/text/atrstck.cxx | 18 +++---
sw/source/core/text/pormulti.cxx | 3 +-
sw/source/core/text/txtfld.cxx | 11 ++--
sw/source/core/txtnode/atrfld.cxx | 25 ++++----
sw/source/core/txtnode/atrref.cxx | 3 +-
sw/source/core/txtnode/atrtox.cxx | 3 +-
sw/source/core/txtnode/modeltoviewhelper.cxx | 2 +-
sw/source/core/txtnode/ndhints.cxx | 16 +++--
sw/source/core/txtnode/ndtxt.cxx | 20 +++---
sw/source/core/txtnode/thints.cxx | 84 +++++++++++++++-----------
sw/source/core/txtnode/txtatr2.cxx | 15 +++--
sw/source/core/txtnode/txtedt.cxx | 2 +-
sw/source/core/undo/rolbck.cxx | 6 +-
sw/source/core/unocore/unoportenum.cxx | 2 +-
sw/source/filter/ascii/ascatr.cxx | 3 +-
23 files changed, 155 insertions(+), 114 deletions(-)

Upstream: cgit.freedesktop.org


  • Share