diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index cea901740..55ac0cadd 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -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); diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 06d1a7e0e..de1826867 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -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"