[Kde-bindings] KDE/kdebindings/generator/parser
Richard Dale
richard.j.dale at gmail.com
Tue Dec 7 16:43:33 UTC 2010
SVN commit 1204500 by rdale:
* Attempt to stop the parser crashing when writing an error message
to the log by not going over the end of the contents text
CCMAIL: kde-bindings at kde.org
BUGS: 258703
M +1 -1 parser.cpp
M +3 -3 rpp/chartools.cpp
M +3 -1 rpp/chartools.h
--- trunk/KDE/kdebindings/generator/parser/parser.cpp #1204499:1204500
@@ -369,7 +369,7 @@
Problem *p = new Problem;
p->file = session->url().str();
p->position = position;
- p->description = msg + " : " + QString::fromUtf8(lineFromContents(session->contents(), p->position.line));
+ p->description = msg + " : " + QString::fromUtf8(lineFromContents(session->size(), session->contents(), p->position.line));
p->source = Problem::Source_Parser;
control->reportProblem(p);
}
--- trunk/KDE/kdebindings/generator/parser/rpp/chartools.cpp #1204499:1204500
@@ -38,10 +38,10 @@
#include <stdio.h>
-QByteArray lineFromContents(const uint* contents, int lineNumber) {
+QByteArray lineFromContents(std::size_t size, const uint* contents, int lineNumber) {
int a1 = 0;
int lineCount = 0;
- while (lineCount < lineNumber) {
+ while (a1 < size && lineCount < lineNumber) {
if (isNewline(contents[a1])) {
lineCount++;
}
@@ -49,7 +49,7 @@
}
int a2 = a1;
- while (!isNewline(contents[a2])) {
+ while (a2 < size && !isNewline(contents[a2])) {
a2++;
}
--- trunk/KDE/kdebindings/generator/parser/rpp/chartools.h #1204499:1204500
@@ -22,6 +22,8 @@
#define CHARTOOLS
#include <QChar>
+#include <cstdlib>
+
#include "../cppparser_export.h"
template<class T>
@@ -83,7 +85,7 @@
CPPPARSER_EXPORT QByteArray stringFromContents(const uint* contents, int count);
///Return the line at the given line number from the contents
-CPPPARSER_EXPORT QByteArray lineFromContents(const uint* contents, int lineNumber);
+CPPPARSER_EXPORT QByteArray lineFromContents(std::size_t size, const uint* contents, int lineNumber);
///Returns a string that has a gap inserted between the tokens(for debugging)
CPPPARSER_EXPORT QByteArray stringFromContentsWithGaps(const PreprocessedContents& contents, int offset = 0, int count = 0);
More information about the Kde-bindings
mailing list