TestMemLeakInFunction: Moved test to cfg test
This commit is contained in:
parent
cc0f61376a
commit
adedb5a888
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <tgmath.h> // frexp
|
||||
|
||||
void bufferAccessOutOf(void) {
|
||||
|
@ -36,6 +37,14 @@ void bufferAccessOutOf(void) {
|
|||
fread(a,1,6,stdout);
|
||||
}
|
||||
|
||||
// memory leak
|
||||
|
||||
void ignoreleak(void) {
|
||||
char *p = (char *)malloc(10);
|
||||
memset(&(p[0]), 0, 10);
|
||||
// cppcheck-suppress memleak
|
||||
}
|
||||
|
||||
// null pointer
|
||||
|
||||
void nullpointer(int value){
|
||||
|
@ -109,8 +118,8 @@ void nullpointer(int value){
|
|||
strtol(0,0,0);
|
||||
|
||||
// #6100 False positive nullPointer - calling mbstowcs(NULL,)
|
||||
res += mbstowcs(0,value,0);
|
||||
res += wcstombs(0,value,0);
|
||||
res += mbstowcs(0,"",0);
|
||||
res += wcstombs(0,L"",0);
|
||||
|
||||
strtok(NULL,"xyz");
|
||||
|
||||
|
|
|
@ -325,7 +325,6 @@ private:
|
|||
TEST_CASE(exit6);
|
||||
TEST_CASE(exit7);
|
||||
TEST_CASE(noreturn);
|
||||
TEST_CASE(stdstring);
|
||||
|
||||
TEST_CASE(strndup_function);
|
||||
TEST_CASE(tmpfile_function);
|
||||
|
@ -3814,24 +3813,11 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: p\n", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void stdstring() {
|
||||
check("void f(std::string foo)\n"
|
||||
"{\n"
|
||||
" char *out = new char[11];\n"
|
||||
" memset(&(out[0]), 0, 1);\n"
|
||||
"}");
|
||||
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: out\n", errout.str());
|
||||
}
|
||||
|
||||
void strndup_function() {
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
check("void f() {\n"
|
||||
" char *out = strndup(\"text\", 3);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: out\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Memory leak: out\n", errout.str());
|
||||
}
|
||||
|
||||
void tmpfile_function() {
|
||||
|
|
Loading…
Reference in New Issue