Debugger: Fix crash on regexp matching

Conversion of QList to QVector required further adaptations.

Instead of trying to match all expressions, break on first match.

Change-Id: I76d67ae876687ac15f3099a0a26eac582ad73c76
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Orgad Shaneh
2014-09-20 23:07:58 +03:00
committed by hjk
parent c218c051c6
commit 1154aab0b7

View File

@@ -1843,21 +1843,21 @@ void DebuggerEngine::validateExecutable(DebuggerStartParameters *sp)
if (QSharedPointer<Utils::ElfMapper> mapper = reader.readSection(".debug_str")) { if (QSharedPointer<Utils::ElfMapper> mapper = reader.readSection(".debug_str")) {
const char *str = mapper->start; const char *str = mapper->start;
const char *limit = str + mapper->fdlen; const char *limit = str + mapper->fdlen;
bool found = false;
while (str < limit) { while (str < limit) {
QString string = QString::fromUtf8(str); const QString string = QString::fromUtf8(str);
auto itExp = globalRegExpSourceMap.begin(); for (auto itExp = globalRegExpSourceMap.begin(), itEnd = globalRegExpSourceMap.end();
auto itEnd = globalRegExpSourceMap.end(); itExp != itEnd;
while (itExp != itEnd) { ++itExp) {
QRegExp exp = itExp->first; QRegExp exp = itExp->first;
int index = exp.indexIn(string); int index = exp.indexIn(string);
if (index != -1) { if (index != -1) {
sp->sourcePathMap.insert(string.left(index) + exp.cap(1), itExp->second); sp->sourcePathMap.insert(string.left(index) + exp.cap(1), itExp->second);
itExp = globalRegExpSourceMap.erase(itExp); found = true;
} else { break;
++itExp;
} }
} }
if (globalRegExpSourceMap.isEmpty()) if (found)
break; break;
const int len = strlen(str); const int len = strlen(str);