Use of memset with size argument zero
Size argument of function in memset
family
is zero
Description
This defect occurs
when you call a function in the memset
family with
size argument zero. Functions include memset
, wmemset
, bzero
, SecureZeroMemory
, RtlSecureZeroMemory
,
and so on.
Risk
void *memset (void *ptr, int value, size_t num)
fills
the first num
bytes of the memory block that ptr
points
to with the specified value
. A zero value of num
renders
the call to memset
redundant. The memory that ptr
points
to:
Remains uninitialized, if not previously initialized.
Is not cleared and can contain sensitive data, if previously initialized.
Fix
Determine if the zero size argument occurs because of a previous error in your code. Fix the error.
Examples
Result Information
Group: Programming |
Language: C | C++ |
Default: Off |
Command-Line Syntax: MEMSET_INVALID_SIZE |
Impact: Medium |
Version History
Introduced in R2015b
See Also
Find defects (-checkers)
| Call to memset with unintended value
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)