From bd98924d1a335fb34e3119a58bae3c0d42493c26 Mon Sep 17 00:00:00 2001 From: Bruno dos Santos de Araujo Date: Wed, 16 Dec 2009 08:50:48 -0400 Subject: Add constraint to avoid index out-of-range errors Reviewer: Lauro Neto --- generators/qtdoc/qtdocgenerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'generators/qtdoc/qtdocgenerator.cpp') diff --git a/generators/qtdoc/qtdocgenerator.cpp b/generators/qtdoc/qtdocgenerator.cpp index 47028813f..03807d525 100644 --- a/generators/qtdoc/qtdocgenerator.cpp +++ b/generators/qtdoc/qtdocgenerator.cpp @@ -742,7 +742,7 @@ QTextStream& operator<<(QTextStream& s, const QtXmlToSphinx::Table &table) QVector rowHeights(table.count()); for (int i = 0, maxI = table.count(); i < maxI; ++i) { const QtXmlToSphinx::TableRow& row = table[i]; - for (int j = 0, maxJ = row.count(); j < maxJ; ++j) { + for (int j = 0, maxJ = std::min(row.count(), colWidths.size()); j < maxJ; ++j) { QStringList rowLines = row[j].data.split('\n'); // cache this would be a good idea foreach (QString str, rowLines) colWidths[j] = std::max(colWidths[j], str.count()); @@ -781,7 +781,7 @@ QTextStream& operator<<(QTextStream& s, const QtXmlToSphinx::Table &table) // Print the table cells for (int rowLine = 0; rowLine < rowHeights[i]; ++rowLine) { // for each line in a row - for (int j = 0, maxJ = row.count(); j < maxJ; ++j) { // for each column + for (int j = 0, maxJ = std::min(row.count(), colWidths.size()); j < maxJ; ++j) { // for each column const QtXmlToSphinx::TableCell& cell = row[j]; QStringList rowLines = cell.data.split('\n'); // FIXME: Cache this!!! if (!j) // First column, so we need print the identation -- cgit v1.2.3