Commit c6349421 authored by Tim Jenssen's avatar Tim Jenssen

fix infinite loop on environment modify()

Task-number: QTCREATORBUG-18335
Change-Id: I9d92f4e85a86a7b498e80d206c5b9ef2d36a17f3
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent 5e0d4e65
......@@ -25,6 +25,7 @@
#include "algorithm.h"
#include "environment.h"
#include <utils/qtcassert.h>
#include <QDir>
#include <QProcessEnvironment>
......@@ -378,6 +379,7 @@ void Environment::modify(const QList<EnvironmentItem> & list)
} else {
// TODO use variable expansion
QString value = item.value;
int replaceCount = 0;
for (int i=0; i < value.size(); ++i) {
if (value.at(i) == QLatin1Char('$')) {
if ((i + 1) < value.size()) {
......@@ -392,6 +394,8 @@ void Environment::modify(const QList<EnvironmentItem> & list)
Environment::const_iterator it = constFind(name);
if (it != constEnd())
value.replace(i, end-i+1, it.value());
++replaceCount;
QTC_ASSERT(replaceCount < 100, break);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment