std.cfg: Ensure null pointer input is correctly handled for fgets() and fgetws().
This commit is contained in:
parent
df84bed889
commit
5be16c3113
|
@ -85,6 +85,26 @@ void bufferAccessOutOfBounds(void)
|
||||||
free(pAlloc1);
|
free(pAlloc1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wchar_t* nullPointer_fgetws(wchar_t* buffer, int n, FILE* stream)
|
||||||
|
{
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)fgetws(NULL,n,stream);
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)fgetws(buffer,n,NULL);
|
||||||
|
// No warning is expected
|
||||||
|
return fgetws(buffer, n, stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* nullPointer_fgets(char *buffer, int n, FILE *stream)
|
||||||
|
{
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)fgets(NULL,n,stream);
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)fgets(buffer,n,NULL);
|
||||||
|
// No warning is expected
|
||||||
|
return fgets(buffer, n, stream);
|
||||||
|
}
|
||||||
|
|
||||||
void memleak_aligned_alloc(void)
|
void memleak_aligned_alloc(void)
|
||||||
{
|
{
|
||||||
// cppcheck-suppress unusedAllocatedMemory
|
// cppcheck-suppress unusedAllocatedMemory
|
||||||
|
|
|
@ -1264,6 +1264,26 @@ void uninitvar_fsetpos(void)
|
||||||
(void)std::fsetpos(stream,ptr);
|
(void)std::fsetpos(stream,ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wchar_t* nullPointer_fgetws(wchar_t* buffer, int n, FILE* stream)
|
||||||
|
{
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)std::fgetws(NULL,n,stream);
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)std::fgetws(buffer,n,NULL);
|
||||||
|
// No warning is expected
|
||||||
|
return std::fgetws(buffer, n, stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* nullPointer_fgets(char *buffer, int n, FILE *stream)
|
||||||
|
{
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)std::fgets(NULL,n,stream);
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)std::fgets(buffer,n,NULL);
|
||||||
|
// No warning is expected
|
||||||
|
return std::fgets(buffer, n, stream);
|
||||||
|
}
|
||||||
|
|
||||||
void uninitvar_fgets(void)
|
void uninitvar_fgets(void)
|
||||||
{
|
{
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
Loading…
Reference in New Issue