editeng/source/editeng/editdoc.cxx  |    9 ++++++---
 editeng/source/editeng/impedit2.cxx |    1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

New commits:
commit 48db2edc9539d2d6d313cd225dadca6edc019559
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Mon Oct 7 19:52:36 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Oct 8 19:34:17 2024 +0200

    cid#1608062 Overflowed constant
    
    Change-Id: I03b3cc85b3571806ad87bf678d83e4c89dca8a8e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174622
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index a4276e7daba9..2e4ac3102ae7 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -3022,6 +3022,7 @@ EditPaM ImpEditEngine::ImpInsertParaBreak( EditPaM& rPaM, 
bool bKeepEndingAttrib
     // Optimization: Do not place unnecessarily many getPos to Listen!
     // Here, as in undo, but also in all other methods.
     sal_Int32 nPos = GetParaPortions().GetPos( pPortion );
+    assert(nPos != EE_PARA_NOT_FOUND);
     ParaPortion* pNewPortion = new ParaPortion( aPaM.GetNode() );
     GetParaPortions().Insert(nPos+1, 
std::unique_ptr<ParaPortion>(pNewPortion));
     ParaAttribsChanged( pNewPortion->GetNode() );
commit c360c2a9a39af716014c610ea44d9e33d2f6fb3a
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Mon Oct 7 19:50:18 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Oct 8 19:34:10 2024 +0200

    cid#1606728 Overflowed integer argument
    
    The problem here is that coverity thinks that ParaPortion::GetLineNumber
    can return -1, which it can, but only if things are already broken,
    so add an assert tbere.
    
    Change-Id: Iceea035edb49bb3e1e0a39a9b63a9176308346ea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174621
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/editeng/source/editeng/editdoc.cxx 
b/editeng/source/editeng/editdoc.cxx
index be2f3b9a8980..541d652bf8f1 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -359,17 +359,20 @@ void ParaPortion::MarkSelectionInvalid(sal_Int32 nStart)
 
 sal_Int32 ParaPortion::GetLineNumber( sal_Int32 nIndex ) const
 {
-    SAL_WARN_IF(!maLineList.Count(), "editeng", "Empty ParaPortion in 
GetLine!");
+    const sal_Int32 nCount = maLineList.Count();
+    assert(nCount > 0 && "Empty ParaPortion in GetLine!");
+    if (nCount == 0)
+        return 0;
     DBG_ASSERT(mbVisible, "Why GetLine() on an invisible paragraph?");
 
-    for ( sal_Int32 nLine = 0; nLine < maLineList.Count(); nLine++ )
+    for ( sal_Int32 nLine = 0; nLine < nCount; nLine++ )
     {
         if (maLineList[nLine].IsIn(nIndex))
             return nLine;
     }
 
     // Then it should be at the end of the last line!
-    DBG_ASSERT(nIndex == maLineList[maLineList.Count() - 1].GetEnd(), "Index 
dead wrong!");
+    DBG_ASSERT(nIndex == maLineList[nCount - 1].GetEnd(), "Index dead wrong!");
     return (maLineList.Count() - 1);
 }
 

Reply via email to