C++: Fix crash when accessing an empty list in Rewrite

Task-number: QTCREATORBUG-14163
Change-Id: I57eca70466bbf5d28d16afafc07ab243206fcff5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Lorenz Haas
2015-03-21 20:10:12 +01:00
parent c097867f3c
commit da67c7c6c9

View File

@@ -63,9 +63,11 @@ public:
{ {
TypeVisitor::accept(ty.type()); TypeVisitor::accept(ty.type());
unsigned flags = ty.flags(); unsigned flags = ty.flags();
if (!temps.isEmpty()) {
flags |= temps.back().flags(); flags |= temps.back().flags();
temps.back().setFlags(flags); temps.back().setFlags(flags);
} }
}
public: public:
RewriteType(Rewrite *r): rewrite(r) {} RewriteType(Rewrite *r): rewrite(r) {}
@@ -73,7 +75,7 @@ public:
FullySpecifiedType operator()(const FullySpecifiedType &ty) FullySpecifiedType operator()(const FullySpecifiedType &ty)
{ {
accept(ty); accept(ty);
return temps.takeLast(); return (!temps.isEmpty()) ? temps.takeLast() : ty;
} }
virtual void visit(UndefinedType *) virtual void visit(UndefinedType *)
@@ -241,7 +243,7 @@ public:
return 0; return 0;
accept(name); accept(name);
return temps.takeLast(); return (!temps.isEmpty()) ? temps.takeLast() : name;
} }
virtual void visit(const QualifiedNameId *name) virtual void visit(const QualifiedNameId *name)