diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 8060bd99f..0be88e33d 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1122,7 +1122,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::listlink(); else if (tok3->str() == ")") break; - else if (Token::Match(tok3->previous(), "(|, %varid% ,|)", varid)) + else if (Token::Match(tok3->previous(), "(|, &| %varid% ,|)", varid)) { use = true; break; diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index e19973043..e657d09ec 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -418,6 +418,8 @@ private: ASSERT_EQUALS(";;;if{dealloc;};if{dealloc;return;}assign;returnuse;", getcode("char *buf, *tmp; tmp = realloc(buf, 40); if (!(tmp)) { free(buf); return; } buf = tmp; return buf;", "buf")); ASSERT_EQUALS(";;if{}", getcode("FILE *f; if (fgets(buf,100,f)){}", "f")); ASSERT_EQUALS(";;alloc;if(var){dealloc;}", getcode("int fd = open(a,b); if (0 < fd) { close(fd); }", "fd")); + ASSERT_EQUALS(";;use;if{}", getcode("char *s; if (x(s)) { }", "s")); + ASSERT_EQUALS(";;use;if{}", getcode("char *s; if (x(&s)) { }", "s")); // switch.. ASSERT_EQUALS(";;switch{case;;break;};", getcode("char *s; switch(a){case 1: break;};", "s"));