Merge pull request #891 from IOBYTE/master

Fix #7963: crash; Variable::setFlag ; gecko-dev , dom/canvas/WebGLTra…
This commit is contained in:
Daniel Marjamäki 2017-04-20 20:51:40 +02:00 committed by GitHub
commit 95dd16892b
2 changed files with 32 additions and 5 deletions

View File

@ -4739,11 +4739,14 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
if (isconst) if (isconst)
varvt.constness |= 1; varvt.constness |= 1;
setValueType(parent->previous(), varvt); setValueType(parent->previous(), varvt);
const_cast<Variable *>(parent->previous()->variable())->setFlags(varvt); Variable * var = const_cast<Variable *>(parent->previous()->variable());
const Type * type = typeStart->tokAt(4)->type(); if (var) {
if (type && type->classScope && type->classScope->definedType) { var->setFlags(varvt);
autoToken->type(type->classScope->definedType); const Type * type = typeStart->tokAt(4)->type();
const_cast<Variable *>(parent->previous()->variable())->type(type->classScope->definedType); if (type && type->classScope && type->classScope->definedType) {
autoToken->type(type->classScope->definedType);
var->type(type->classScope->definedType);
}
} }
} }
} }

View File

@ -326,6 +326,7 @@ private:
TEST_CASE(auto3); TEST_CASE(auto3);
TEST_CASE(auto4); TEST_CASE(auto4);
TEST_CASE(auto5); TEST_CASE(auto5);
TEST_CASE(auto6); // #7963 (segmentation fault)
} }
void array() { void array() {
@ -4862,6 +4863,29 @@ private:
ASSERT(db && vartok && vartok->variable() && vartok->variable()->typeStartToken()->str() == "int"); ASSERT(db && vartok && vartok->variable() && vartok->variable()->typeStartToken()->str() == "int");
} }
void auto6() { // #7963 (segmentation fault)
GET_SYMBOL_DB("class WebGLTransformFeedback final\n"
": public nsWrapperCache\n"
", public WebGLRefCountedObject < WebGLTransformFeedback >\n"
", public LinkedListElement < WebGLTransformFeedback >\n"
"{\n"
"private :\n"
"std :: vector < IndexedBufferBinding > mIndexedBindings ;\n"
"} ;\n"
"struct IndexedBufferBinding\n"
"{\n"
"IndexedBufferBinding ( ) ;\n"
"} ;\n"
"const decltype ( WebGLTransformFeedback :: mBuffersForTF ) &\n"
"WebGLTransformFeedback :: BuffersForTF ( ) const\n"
"{\n"
"mBuffersForTF . clear ( ) ;\n"
"for ( const auto & cur : mIndexedBindings ) {}\n"
"return mBuffersForTF ;\n"
"}");
ASSERT_EQUALS(true, db != nullptr); // not null
}
}; };
REGISTER_TEST(TestSymbolDatabase) REGISTER_TEST(TestSymbolDatabase)