From 86c9387987ec827c13bcb298c218173d69ab2602 Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Sat, 5 Dec 2015 18:43:29 +0100 Subject: [PATCH] #7182 crash: CheckMemoryLeak::functionReturnType() --- lib/checkmemoryleak.cpp | 3 ++- test/testmemleak.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 00e1674d9..bcf8cad3a 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -344,7 +344,8 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::functionReturnType(const Function* f const Token* tok = tok2->astOperand1(); if (Token::Match(tok, ".|::")) tok = tok->astOperand2() ? tok->astOperand2() : tok->astOperand1(); - varid = tok->varId(); + if (tok) + varid = tok->varId(); break; } } diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 6fcc82507..6f9ce3b00 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -5712,6 +5712,14 @@ private: " malloc();\n" "}"); ASSERT_EQUALS("", errout.str()); + + // #7182 "crash: CheckMemoryLeak::functionReturnType()" + check("template auto unary_right_comma (Ts... ts) { return (ts , ...); }\n" + "template auto binary_left_comma (T x, Ts... ts) { return (x , ... , ts); }\n" + "int main() {\n" + " unary_right_comma (a);\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void smartPointerFunctionParam() {