Fix CI; Cppcheck find some more unusedAllocatedMemory violations in test/cfg/..
This commit is contained in:
parent
fd31f0846e
commit
45eb9f82a0
|
@ -940,9 +940,11 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
|
|||
else if (var && var->mType == Variables::pointer &&
|
||||
Token::Match(start, "%name% =") &&
|
||||
findAllocFuncCallToken(start->next()->astOperand2(), mSettings->library)) {
|
||||
bool allocate = true;
|
||||
|
||||
const Token *allocFuncCallToken = findAllocFuncCallToken(start->next()->astOperand2(), mSettings->library);
|
||||
const Library::AllocFunc *allocFunc = mSettings->library.getAllocFuncInfo(allocFuncCallToken);
|
||||
|
||||
bool allocateMemory = !allocFunc || Library::ismemory(allocFunc->groupId);
|
||||
|
||||
if (allocFuncCallToken->str() == "new") {
|
||||
const Token *type = allocFuncCallToken->next();
|
||||
|
@ -956,11 +958,11 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
|
|||
if (!type->isStandardType()) {
|
||||
const Variable *variable = start->variable();
|
||||
if (!variable || !isRecordTypeWithoutSideEffects(variable->type()))
|
||||
allocate = false;
|
||||
allocateMemory = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (allocate)
|
||||
if (allocateMemory)
|
||||
variables.allocateMemory(varid1, tok);
|
||||
else
|
||||
variables.write(varid1, tok);
|
||||
|
|
|
@ -197,6 +197,7 @@ void memleak_getaddrinfo()
|
|||
|
||||
void memleak_mmap(int fd)
|
||||
{
|
||||
// cppcheck-suppress unusedAllocatedMemory
|
||||
// cppcheck-suppress unreadVariable
|
||||
void *addr = mmap(NULL, 255, PROT_NONE, MAP_PRIVATE, fd, 0);
|
||||
// cppcheck-suppress memleak
|
||||
|
|
|
@ -48,6 +48,7 @@ void PyMem_Malloc_memleak()
|
|||
|
||||
void PyMem_Malloc_mismatchAllocDealloc()
|
||||
{
|
||||
// cppcheck-suppress unusedAllocatedMemory
|
||||
char * pBuf1 = PyMem_Malloc(10);
|
||||
// cppcheck-suppress mismatchAllocDealloc
|
||||
free(pBuf1);
|
||||
|
|
|
@ -87,6 +87,7 @@ void bufferAccessOutOfBounds(void)
|
|||
|
||||
void memleak_aligned_alloc(void)
|
||||
{
|
||||
// cppcheck-suppress unusedAllocatedMemory
|
||||
// cppcheck-suppress unreadVariable
|
||||
char * alignedBuf = aligned_alloc(8, 16);
|
||||
// cppcheck-suppress memleak
|
||||
|
@ -1118,6 +1119,7 @@ void uninitvar_calloc(void)
|
|||
{
|
||||
size_t nitems;
|
||||
size_t size;
|
||||
// cppcheck-suppress unusedAllocatedMemory
|
||||
// cppcheck-suppress uninitvar
|
||||
int * p = (int*) calloc(nitems, size);
|
||||
free(p);
|
||||
|
@ -2598,6 +2600,7 @@ void uninitvar_longjmp(void)
|
|||
void uninitvar_malloc(void)
|
||||
{
|
||||
size_t size;
|
||||
// cppcheck-suppress unusedAllocatedMemory
|
||||
// cppcheck-suppress uninitvar
|
||||
int *p = (int*)malloc(size);
|
||||
free(p);
|
||||
|
|
|
@ -403,6 +403,7 @@ void nullPointer()
|
|||
|
||||
void memleak_malloca()
|
||||
{
|
||||
// cppcheck-suppress unusedAllocatedMemory
|
||||
// cppcheck-suppress unreadVariable
|
||||
void *pMem = _malloca(10);
|
||||
// cppcheck-suppress memleak
|
||||
|
|
Loading…
Reference in New Issue