changeset 2086:a82b8ba0eb8e

fix table leak with overlapping spans
author corvid <corvid@lavabit.com>
date Sat, 11 Jun 2011 22:17:53 +0000
parents 7c04f8d91d24
children ea7b25dcf495
files dw/table.cc
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dw/table.cc	Tue Jun 07 12:09:20 2011 +0200
+++ b/dw/table.cc	Sat Jun 11 22:17:53 2011 +0000
@@ -320,11 +320,19 @@
    for (int col = 0; col < colspanEff; col++)
       for (int row = 0; row < rowspan; row++)
          if (!(col == 0 && row == 0)) {
+            int i = (curRow + row) * numCols + curCol + col;
+
+            child = children->get(i);
+            if (child) {
+               MSG("Overlapping spans in table.\n");
+               assert(child->type == Child::SPAN_SPACE);
+               delete child;
+            }
             child = new Child ();
             child->type = Child::SPAN_SPACE;
             child->spanSpace.startCol = curCol;
             child->spanSpace.startRow = curRow;
-            children->set ((curRow + row) * numCols + curCol + col, child);
+            children->set (i, child);
          }
 
    // Set the "root" cell.