]> git.lyx.org Git - features.git/commitdiff
Fix a nasty "unsigned means trouble" bug.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 11 Jan 2000 11:23:48 +0000 (11:23 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 11 Jan 2000 11:23:48 +0000 (11:23 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@415 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/lyxparagraph.h
src/paragraph.C

index 2d530d50ba221c7c0caa194f127ef774ecefd992..d2817af56334b5e387b6d0771328e8662b97664e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2000-01-11  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * src/paragraph.C (BreakParagraph): do not reserve space on text
+       if we don't need to (otherwise, if pos_end < pos, we end up
+       reserving huge amounts of memory due to bad unsigned karma).
+       (BreakParagraphConservative): ditto, although I have not seen
+       evidence the bug can happen here.
+
+       * src/lyxparagraph.h: add a using std::list.
+
 2000-01-11  Juergen Vigna  <jug@sad.it>
 
        * src/menus.C (MenuDocu): output an Alert if the documentation-file
index 87deafe22fdddea4ee04fede00d3a8334da5eb3a..067a5ca4a13239f524d81634de33669734f7dafd 100644 (file)
@@ -26,7 +26,6 @@
 #include "layout.h"
 #include "support/block.h"
 
-
 #define NEW_INSETTABLE 1
 #define NEW_FONTTABLE 1
 
@@ -35,6 +34,8 @@ class LyXBuffer;
 class TexRow;
 struct LaTeXFeatures;
 
+using std::list;
+
 /// A LyXParagraph holds all text, attributes and insets in a text paragraph
 class LyXParagraph  {
 public:
index 2bb18268d0fb1187cde76067c496d485f5ad9d1e..d7c577671da8b3256b45fb4b6ad40e41a835f7d0 100644 (file)
@@ -1686,7 +1686,8 @@ void LyXParagraph::BreakParagraph(LyXParagraph::size_type pos,
                        pos_first++;
 
                pos_end = pos_first + par->text.size() - 1;
-               tmp->text.reserve(pos_end - pos);
+               if (pos_end > pos)
+                       tmp->text.reserve(pos_end - pos);
 
                for (i = pos; i <= pos_end; i++) {
                        par->CutIntoMinibuffer(i - pos_first);
@@ -1853,7 +1854,8 @@ void LyXParagraph::BreakParagraphConservative(LyXParagraph::size_type pos)
                // InsertFromMinibuffer will enlarge the memory (it uses
                // InsertChar of course). But doing it by hand
                // is MUCH faster! (only one time, not thousend times!!)
-               tmp->text.reserve(pos_end - pos);
+               if (pos_end > pos)
+                       tmp->text.reserve(pos_end - pos);
 
                for (i = pos; i <= pos_end; i++) {