[LyX/master] Limit the number of iterations for some tabular features in math

Jean-Marc Lasgouttes lasgouttes at lyx.org
Wed Sep 11 11:31:29 UTC 2024


commit 716e20ae1bd7ab012c953d1dad18c88859e4252d
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Wed Sep 11 13:29:20 2024 +0200

    Limit the number of iterations for some tabular features in math
    
    Try to please Coverity scan.
---
 development/coverity_modeling.cpp | 11 +++++++++++
 src/mathed/InsetMathGrid.cpp      |  3 ++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/development/coverity_modeling.cpp b/development/coverity_modeling.cpp
index 984464655a..7e8cb63231 100644
--- a/development/coverity_modeling.cpp
+++ b/development/coverity_modeling.cpp
@@ -36,4 +36,15 @@ void lyxbreaker(void const * data, const char * hint, int size)
 }
 
 
+template<class T>
+void CoordCache<T>::check(T const * thing, char const * hint) const
+{
+	typename cache_type::const_iterator it = data_.find(thing);
+
+	if (it == data_.end() || it->second.pos.x == -10000)
+		__coverity_panic__();
+}
+
+
+
 }
diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index c775ff4943..f17702a169 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -59,11 +59,12 @@ static docstring verboseHLine(int n)
 }
 
 
+// read a number to be used as an iteration count (limited arbitrary to 1000)
 static int extractInt(istream & is)
 {
 	int num = 1;
 	is >> num;
-	return (num == 0) ? 1 : num;
+	return min(max(num, 1), 1000);
 }
 
 


More information about the lyx-cvs mailing list