* Fix #10838 Crash/nullptr deref in getEndOfExprScope() * Format
This commit is contained in:
parent
78dd29ada3
commit
2dd6c75b35
|
@ -3522,6 +3522,8 @@ static void valueFlowForwardLifetime(Token * tok, TokenList *tokenlist, ErrorLog
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Token* expr = getLHSVariableToken(parent);
|
const Token* expr = getLHSVariableToken(parent);
|
||||||
|
if (!expr)
|
||||||
|
return;
|
||||||
|
|
||||||
const Token* endOfVarScope = getEndOfExprScope(expr);
|
const Token* endOfVarScope = getEndOfExprScope(expr);
|
||||||
|
|
||||||
|
|
|
@ -700,6 +700,19 @@ private:
|
||||||
"};\n";
|
"};\n";
|
||||||
lifetimes = lifetimeValues(code, "=");
|
lifetimes = lifetimeValues(code, "=");
|
||||||
ASSERT_EQUALS(true, lifetimes.empty());
|
ASSERT_EQUALS(true, lifetimes.empty());
|
||||||
|
|
||||||
|
code = "struct T {\n" // #10838
|
||||||
|
" void f();\n"
|
||||||
|
" double d[4][4];\n"
|
||||||
|
"};\n"
|
||||||
|
"void T::f() {\n"
|
||||||
|
" auto g = [this]() -> double(&)[4] {\n"
|
||||||
|
" double(&q)[4] = d[0];\n"
|
||||||
|
" return q;\n"
|
||||||
|
" };\n"
|
||||||
|
"}\n";
|
||||||
|
lifetimes = lifetimeValues(code, "return"); // don't crash
|
||||||
|
ASSERT_EQUALS(true, lifetimes.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowArrayElement() {
|
void valueFlowArrayElement() {
|
||||||
|
|
Loading…
Reference in New Issue