Commit ebcd4ce8 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

C++: fix possible nullptr deref.

Pointed out by the clang static analyzer.

Change-Id: I69ab89e651cbcb13606d5d93a05f629172cbd9e0
Reviewed-by: default avatarNikolai Kosjar <>
parent 0ed37746
......@@ -1884,7 +1884,7 @@ bool Bind::visit(SimpleDeclarationAST *ast)
const ExpressionAST *initializer = it->value->initializer;
if (!initializer && declaratorId)
translationUnit()->error(location(declaratorId->name, ast->firstToken()), "auto-initialized variable must have an initializer");
else {
else if (initializer) {
unsigned startOfExpression = initializer->firstToken();
unsigned endOfExpression = initializer->lastToken();
decl->setInitializer(asStringLiteral(startOfExpression, endOfExpression));
Supports Markdown
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