Commit 1c12b30b authored by hjk's avatar hjk
Browse files

Prevent indefinite recursion in macro expansion



Task-number: QTCREATORBUG-13315
Change-Id: Ibf963569bdebf8a791f0a7ceb8cd010efed99dad
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 2d7af0d7
......@@ -29,6 +29,7 @@
****************************************************************************/
#include "macroexpander.h"
#include "qtcassert.h"
#include "qtcprocess.h"
#include "algorithm.h"
......@@ -49,7 +50,7 @@ const char kFileBaseNamePostfix[] = ":FileBaseName";
class MacroExpanderPrivate : public AbstractMacroExpander
{
public:
MacroExpanderPrivate() : m_accumulating(false) {}
MacroExpanderPrivate() : m_accumulating(false), m_lockDepth(0) {}
bool resolveMacro(const QString &name, QString *ret)
{
......@@ -108,6 +109,8 @@ public:
QVector<MacroExpanderProvider> m_subProviders;
QVector<MacroExpander *> m_subExpanders; // Not owned
bool m_accumulating;
int m_lockDepth;
};
} // Internal
......@@ -261,8 +264,16 @@ QString MacroExpander::value(const QByteArray &variable, bool *found) const
*/
QString MacroExpander::expand(const QString &stringWithVariables) const
{
if (d->m_lockDepth > 3) // Limit recursion.
return QString();
++d->m_lockDepth;
QString res = stringWithVariables;
Utils::expandMacros(&res, d);
--d->m_lockDepth;
return res;
}
......
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