Fixed #5525 (Closing a socket file descriptor gives an error: Mismatching allocation and deallocation)
This commit is contained in:
parent
b909aa0e4f
commit
a9943fe6d0
|
@ -162,7 +162,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getAllocationType(const Token *tok2,
|
|||
return File;
|
||||
|
||||
if (settings1->standards.posix) {
|
||||
if (Token::Match(tok2, "open|openat|creat|mkstemp|mkostemp (")) {
|
||||
if (Token::Match(tok2, "open|openat|creat|mkstemp|mkostemp|socket (")) {
|
||||
// simple sanity check of function parameters..
|
||||
// TODO: Make such check for all these functions
|
||||
unsigned int num = countParameters(tok2);
|
||||
|
|
|
@ -4242,6 +4242,7 @@ private:
|
|||
// Test that posix.cfg is configured correctly
|
||||
void posixcfg() {
|
||||
Settings settings;
|
||||
settings.standards.posix = true;
|
||||
LOAD_LIB_2(settings.library, "posix.cfg");
|
||||
|
||||
const char code[] = "void leaks() {\n"
|
||||
|
@ -4259,6 +4260,13 @@ private:
|
|||
"[test.cpp:5]: (error) Resource leak: leak2\n"
|
||||
"[test.cpp:5]: (error) Resource leak: leak3\n", errout.str());
|
||||
|
||||
const char code2[] = "int main() {\n"
|
||||
" int fileDescriptor = socket(AF_INET, SOCK_STREAM, 0);\n"
|
||||
" close(fileDescriptor);\n"
|
||||
"}";
|
||||
check(code2, &settings);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
LOAD_LIB_2(settings.library, "gtk.cfg");
|
||||
|
||||
check("void f(char *a) {\n"
|
||||
|
|
Loading…
Reference in New Issue