std.cfg: Moved strdup() from posix.cfg to std.cfg since its now part of C23.

This commit is contained in:
orbitcowboy 2022-04-27 12:41:40 +02:00
parent d4bd232264
commit 6796f9daa2
3 changed files with 24 additions and 13 deletions

View File

@ -1187,17 +1187,6 @@ The obsolescent function 'usleep' is called. POSIX.1-2001 declares usleep() func
<not-bool/>
</arg>
</function>
<!-- char *strdup(const char *s); -->
<function name="strdup">
<noreturn>false</noreturn>
<returnValue type="char *"/>
<use-retval/>
<arg nr="1">
<not-null/>
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- char *strndup(const char *s, size_t n); -->
<function name="strndup">
<noreturn>false</noreturn>
@ -5724,11 +5713,10 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<dealloc>free</dealloc>
</memory>
<memory>
<alloc init="true" buffer-size="strdup">strdup</alloc>
<alloc init="true">strndup</alloc>
<alloc init="true">wcsdup</alloc>
<dealloc>free</dealloc>
</memory>
</memory>
<memory>
<alloc init="true">mmap</alloc>
<alloc init="true">mmap64</alloc>

View File

@ -7976,6 +7976,17 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<not-bool/>
</arg>
</function>
<!-- char *strdup(const char *s); -->
<function name="strdup">
<noreturn>false</noreturn>
<returnValue type="char *"/>
<use-retval/>
<arg nr="1">
<not-null/>
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- int mtx_init( mtx_t* mutex, int type ); // since C11 -->
<function name="mtx_init">
<noreturn>false</noreturn>
@ -8185,6 +8196,10 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<realloc init="false" buffer-size="calloc:2,3">reallocarray</realloc>
<dealloc>free</dealloc>
</memory>
<memory>
<alloc init="true" buffer-size="strdup">strdup</alloc>
<dealloc>free</dealloc>
</memory>
<resource>
<alloc init="true">fopen</alloc>
<alloc init="true">tmpfile</alloc>

View File

@ -2891,6 +2891,14 @@ void uninitvar_vprintf(char *Format, va_list Arg)
(void)vprintf(Format,arg2);
}
void memleak_strdup (char *s) // #9328
{
char *s1 = strdup(s);
printf("%s",s1);
free(s); // s1 is not freed
// cppcheck-suppress memleak
}
void uninitvar_vwprintf(wchar_t *Format, va_list Arg)
{
wchar_t * format1, * format2;