Commit 1b90b80f authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

C++: Fix potential crash



If no template is found, findSpecialization will crash

Task-number: QTCREATORBUG-14748
Change-Id: I94b970e6eb994f0a8d85a4b996e52fcff0affef3
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 99dea548
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <cplusplus/Names.h> #include <cplusplus/Names.h>
#include <cplusplus/Scope.h> #include <cplusplus/Scope.h>
#include <cplusplus/Control.h> #include <cplusplus/Control.h>
#include <cplusplus/cppassert.h>
#include <QStack> #include <QStack>
#include <QHash> #include <QHash>
...@@ -1255,12 +1256,14 @@ LookupScopePrivate *LookupScopePrivate::nestedType(const Name *name, LookupScope ...@@ -1255,12 +1256,14 @@ LookupScopePrivate *LookupScopePrivate::nestedType(const Name *name, LookupScope
if (baseTemplate) if (baseTemplate)
break; break;
} }
if (LookupScopePrivate *specialization = if (baseTemplate) {
findSpecialization(baseTemplate, templId, specializations, origin)) { if (LookupScopePrivate *specialization =
reference = specialization; findSpecialization(baseTemplate, templId, specializations, origin)) {
if (Q_UNLIKELY(debug)) { reference = specialization;
Overview oo; if (Q_UNLIKELY(debug)) {
qDebug() << "picked specialization" << oo(specialization->_name); Overview oo;
qDebug() << "picked specialization" << oo(specialization->_name);
}
} }
} }
} }
...@@ -1970,6 +1973,7 @@ FullySpecifiedType CreateBindings::resolveTemplateArgument(Clone &cloner, ...@@ -1970,6 +1973,7 @@ FullySpecifiedType CreateBindings::resolveTemplateArgument(Clone &cloner,
unsigned index) unsigned index)
{ {
FullySpecifiedType ty; FullySpecifiedType ty;
CPP_ASSERT(specialization && instantiation, return ty);
const TypenameArgument *tParam = 0; const TypenameArgument *tParam = 0;
if (Symbol *tArgument = specialization->templateParameterAt(index)) if (Symbol *tArgument = specialization->templateParameterAt(index))
......
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