posix.cfg: Improved configuration for 'mkstemp()' and added test cases to ensure resource leaks are caught.
This commit is contained in:
parent
0144db2490
commit
719eb25ba9
|
@ -825,7 +825,6 @@ The obsolescent function 'usleep' is called. POSIX.1-2001 declares usleep() func
|
||||||
<!-- int mkstemp(char *template); -->
|
<!-- int mkstemp(char *template); -->
|
||||||
<function name="mkstemp">
|
<function name="mkstemp">
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
|
||||||
<returnValue type="int"/>
|
<returnValue type="int"/>
|
||||||
<arg nr="1">
|
<arg nr="1">
|
||||||
<not-null/>
|
<not-null/>
|
||||||
|
@ -4583,6 +4582,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
|
||||||
</memory>
|
</memory>
|
||||||
<resource>
|
<resource>
|
||||||
<alloc init="true">open</alloc>
|
<alloc init="true">open</alloc>
|
||||||
|
<alloc init="true">mkstemp</alloc>
|
||||||
<alloc init="true">creat</alloc>
|
<alloc init="true">creat</alloc>
|
||||||
<alloc init="true">openat</alloc>
|
<alloc init="true">openat</alloc>
|
||||||
<alloc init="true">socket</alloc>
|
<alloc init="true">socket</alloc>
|
||||||
|
|
|
@ -134,6 +134,24 @@ void resourceLeak_fdopen(int fd)
|
||||||
// cppcheck-suppress resourceLeak
|
// cppcheck-suppress resourceLeak
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resourceLeak_mkstemp(char *template)
|
||||||
|
{
|
||||||
|
// cppcheck-suppress unreadVariable
|
||||||
|
int fp = mkstemp(template);
|
||||||
|
// cppcheck-suppress resourceLeak
|
||||||
|
}
|
||||||
|
|
||||||
|
void no_resourceLeak_mkstemp_01(char *template)
|
||||||
|
{
|
||||||
|
int fp = mkstemp(template);
|
||||||
|
close(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
int no_resourceLeak_mkstemp_02(char *template)
|
||||||
|
{
|
||||||
|
return mkstemp(template);
|
||||||
|
}
|
||||||
|
|
||||||
void resourceLeak_fdopendir(int fd)
|
void resourceLeak_fdopendir(int fd)
|
||||||
{
|
{
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
|
|
Loading…
Reference in New Issue