sw/source/core/text/txtfrm.cxx | 2 ++ 1 file changed, 2 insertions(+) New commits: commit edafe2784f7e3edd6207fae1d1e82c9596da4925 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Feb 3 17:21:19 2023 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Feb 4 11:28:31 2023 +0000
Avoid UB as seen in https://ci.libreoffice.org/job/lo_ubsan/2671/ after commit 333183d9a72d1e2b7ae65145092efec5e357ad14 ("tdf#153304: Add undo entries and set modified in SwXFrame::setProperty*", 2023-02-02): [_RUN_____] testImagePropsCreateUndoAndModifyDoc::TestBody warn:sal.file:4195:4195:sal/osl/unx/file_misc.cxx:401: Invalid directory URL warn:basic:4195:4195:basic/source/uno/namecont.cxx:953: Cannot access extensions! warn:sal.file:4195:4195:sal/osl/unx/file_misc.cxx:401: Invalid directory URL warn:basic:4195:4195:basic/source/uno/namecont.cxx:953: Cannot access extensions! warn:legacy.osl:4195:4195:sw/source/core/text/porfly.cxx:198: CalcFlyPos: Not Found! warn:legacy.osl:4195:4195:sw/source/core/text/txtfrm.cxx:3092: Prepare: Why me? /include/o3tl/strong_int.hxx:143:40: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' #0 0x7f79b14fee7a in o3tl::strong_int<int, Tag_TextFrameIndex> o3tl::operator+<int, Tag_TextFrameIndex>(o3tl::strong_int<int, Tag_TextFrameIndex> const&, o3tl::strong_int<int, Tag_TextFrameIndex> const&) /include/o3tl/strong_int.hxx:143:40 #1 0x7f79b553f7a5 in SwTextFrame::IsIdxInside(o3tl::strong_int<int, Tag_TextFrameIndex>, o3tl::strong_int<int, Tag_TextFrameIndex>) const /sw/source/core/text/txtfrm.cxx:1665:71 #2 0x7f79b559be6a in SwTextFrame::InvalidateRange(SwCharRange const&, long) /sw/source/core/text/txtfrm.cxx:1689:10 #3 0x7f79b5566a79 in SwTextFrame::Prepare(PrepareHint, void const*, bool) /sw/source/core/text/txtfrm.cxx:3093:17 #4 0x7f79b438c1b5 in SwFlyInContentFrame::SwClientNotify(SwModify const&, SfxHint const&) /sw/source/core/layout/flyincnt.cxx:137:28 #5 0x7f79b17c06e2 in SwModify::CallSwClientNotify(SfxHint const&) const /sw/source/core/attr/calbck.cxx:322:18 #6 0x7f79b17c09e5 in sw::BroadcastingModify::CallSwClientNotify(SfxHint const&) const /sw/source/core/attr/calbck.cxx:327:15 #7 0x7f79b17be1ef in SwModify::SwClientNotify(SwModify const&, SfxHint const&) /sw/source/core/attr/calbck.cxx:313:5 #8 0x7f79b1801e06 in SwFormat::SwClientNotify(SwModify const&, SfxHint const&) /sw/source/core/attr/format.cxx:314:19 #9 0x7f79b414fa7c in SwFrameFormat::SwClientNotify(SwModify const&, SfxHint const&) /sw/source/core/layout/atrfrm.cxx:2713:15 #10 0x7f79b17c0f13 in sw::ClientNotifyAttrChg(SwModify&, SwAttrSet const&, SwAttrSet&, SwAttrSet&) /sw/source/core/attr/calbck.cxx:336:13 #11 0x7f79b18090b5 in SwFormat::SetFormatAttr(SfxPoolItem const&) /sw/source/core/attr/format.cxx:520:13 #12 0x7f79b23c2e54 in SwDoc::SetFlyFrameAnchor(SwFrameFormat&, SfxItemSet&, bool) /sw/source/core/doc/docfly.cxx:326:13 #13 0x7f79b23cac22 in lcl_SetFlyFrameAttr(SwDoc&, signed char (SwDoc::*)(SwFrameFormat&, SfxItemSet&, bool), SwFrameFormat&, SfxItemSet&) /sw/source/core/doc/docfly.cxx:451:17 #14 0x7f79b23ca43d in SwDoc::SetFlyFrameAttr(SwFrameFormat&, SfxItemSet&) /sw/source/core/doc/docfly.cxx:560:23 #15 0x7f79b64818d2 in SwXFrame::setPropertyValue(rtl::OUString const&, com::sun::star::uno::Any const&) /sw/source/core/unocore/unoframe.cxx:1921:36 #16 0x7f79d562de12 in testImagePropsCreateUndoAndModifyDoc::TestBody() /sw/qa/core/undo/undo.cxx:136:13 ... See https://gerrit.libreoffice.org/c/core/+/146484/7#message-8ce5de47f17cc701fc58b932e80b1de8469053bf Hope it makes sense. Change-Id: Id5c86ed4c093993557a24e00b3288ccdfa4de2ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146542 Reviewed-by: Stephan Bergmann <sberg...@redhat.com> Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit 274587f634e57b59b34f352409453b394064cadd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146522 Tested-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 86cfe6555431..aa371cd3df63 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1657,6 +1657,8 @@ TextFrameIndex SwTextFrame::FindBrk(std::u16string_view aText, bool SwTextFrame::IsIdxInside(TextFrameIndex const nPos, TextFrameIndex const nLen) const { + if (nPos == TextFrameIndex(COMPLETE_STRING)) // the "not found" range + return false; // Silence over-eager warning emitted at least by GCC trunk towards 6: #if defined __GNUC__ && !defined __clang__ #pragma GCC diagnostic push