]> git.lyx.org Git - features.git/commitdiff
make out-of-bound access impossible
authorPeter Kümmel <syntheticpp@gmx.net>
Sat, 30 Dec 2006 18:24:25 +0000 (18:24 +0000)
committerPeter Kümmel <syntheticpp@gmx.net>
Sat, 30 Dec 2006 18:24:25 +0000 (18:24 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16444 a592a061-630c-0410-9148-cb99ea01b6c8

src/TextMetrics.C

index fcaff757ce2912ec401afd5cff58115a1c796c48..64284be6abd3e526d2fc21daefc79f05bf239a67 100644 (file)
@@ -83,16 +83,18 @@ int numberOfLabelHfills(Paragraph const & par, Row const & row)
 
 int numberOfHfills(Paragraph const & par, Row const & row)
 {
-       pos_type const last = row.endpos();
+       pos_type last = row.endpos();
        pos_type first = row.pos();
+       pos_type const par_size = par.size();
 
        // hfill *DO* count at the beginning of paragraphs!
        if (first) {
-               while (first < last && par.isHfill(first))
+               while (first < last && first < par_size && par.isHfill(first))
                        ++first;
        }
 
        first = max(first, par.beginOfBody());
+       last = min(last, par_size);
 
        int n = 0;
        for (pos_type p = first; p < last; ++p) {