Fix #7963: crash; Variable::setFlag ; gecko-dev , dom/canvas/WebGLTransformFeedback.cpp

This commit is contained in:
Robert Reif 2017-04-20 10:03:29 -04:00
parent c44b055fc1
commit 69d18d9c29
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());
if (var) {
var->setFlags(varvt);
const Type * type = typeStart->tokAt(4)->type(); const Type * type = typeStart->tokAt(4)->type();
if (type && type->classScope && type->classScope->definedType) { if (type && type->classScope && type->classScope->definedType) {
autoToken->type(type->classScope->definedType); autoToken->type(type->classScope->definedType);
const_cast<Variable *>(parent->previous()->variable())->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)