Fixed crash reported in #4076
This commit is contained in:
parent
f238f3fad5
commit
4fb464982c
|
@ -243,7 +243,7 @@ bool CheckAutoVariables::returnTemporary(const Token *tok) const
|
||||||
bool retvalue = false; // is there such a function that returns a value?
|
bool retvalue = false; // is there such a function that returns a value?
|
||||||
|
|
||||||
for (scope = symbolDatabase->scopeList.begin(); !retref && scope != symbolDatabase->scopeList.end(); ++scope) {
|
for (scope = symbolDatabase->scopeList.begin(); !retref && scope != symbolDatabase->scopeList.end(); ++scope) {
|
||||||
if (scope->type == Scope::eFunction && scope->function->type != Function::eConstructor && scope->function->type != Function::eCopyConstructor) {
|
if (scope->type == Scope::eFunction && scope->function && scope->function->type != Function::eConstructor && scope->function->type != Function::eCopyConstructor) {
|
||||||
if (scope->className == funcname) {
|
if (scope->className == funcname) {
|
||||||
retref = scope->classDef->strAt(-1) == "&";
|
retref = scope->classDef->strAt(-1) == "&";
|
||||||
if (!retref) {
|
if (!retref) {
|
||||||
|
|
|
@ -557,6 +557,12 @@ private:
|
||||||
" return foo();\n"
|
" return foo();\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// Don't crash with function in unknown scope (#4076)
|
||||||
|
check("X& a::Bar() {}"
|
||||||
|
"X& foo() {"
|
||||||
|
" return Bar();"
|
||||||
|
"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
void returnReference3() {
|
void returnReference3() {
|
||||||
|
|
Loading…
Reference in New Issue