ProjectExplorer: Fix crash

One must not call std::next() on a non-dereferenceable iterator.

Change-Id: Id40341f808a3781f91f8aef1930bb76a397e8053
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-12-10 13:42:10 +01:00
parent 017ed74400
commit ef135cc549

View File

@@ -166,12 +166,12 @@ QList<QByteArray> Macro::tokenizeLine(const QByteArray &line)
const auto begin = normalizedLine.begin(); const auto begin = normalizedLine.begin();
auto first = std::find(normalizedLine.begin(), normalizedLine.end(), ' '); auto first = std::find(normalizedLine.begin(), normalizedLine.end(), ' ');
auto second = std::find(std::next(first), normalizedLine.end(), ' ');
const auto end = normalizedLine.end(); const auto end = normalizedLine.end();
QList<QByteArray> tokens; QList<QByteArray> tokens;
if (first != end) { if (first != end) {
auto second = std::find(std::next(first), normalizedLine.end(), ' ');
tokens.append(QByteArray(begin, int(std::distance(begin, first)))); tokens.append(QByteArray(begin, int(std::distance(begin, first))));
std::advance(first, 1); std::advance(first, 1);