From 716e20ae1bd7ab012c953d1dad18c88859e4252d Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 11 Sep 2024 13:29:20 +0200 Subject: [PATCH] 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 +void CoordCache::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); }