commit b06ee6878fc3ebd98077a5848120eedd37a93e5c
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Thu Apr 3 14:53:25 2025 +0200

    Avoid integer overflow (spotted by Coverity Scan)
---
 src/DocIterator.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/DocIterator.cpp b/src/DocIterator.cpp
index 1e3d5c56b1..89f4d04cdd 100644
--- a/src/DocIterator.cpp
+++ b/src/DocIterator.cpp
@@ -577,9 +577,11 @@ bool DocIterator::fixIfBroken()
                CursorSlice & cs = slices_[i];
                if (&cs.inset() != inset || ! cs.inset().isActive()) {
                        // the whole slice is wrong, chop off this as well
-                       --i;
                        LYXERR(Debug::DEBUG, "fixIfBroken(): inset changed");
-                       break;
+                       // The code is different from below to avoid doing --i 
when i == 0.
+                       LYXERR(Debug::DEBUG, "fixIfBroken(): cursor chopped 
after " << i);
+                       resize(i);
+                       return true;
                } else if (cs.idx() > cs.lastidx()) {
                        cs.idx() = cs.lastidx();
                        cs.pit() = cs.lastpit();
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to