Missing reset of freed pointer
Pointer free
not followed by a reset statement to clear
leftover data
Description
This defect occurs when a pointer is freed and not reassigned another value. After freeing a pointer, the memory data is still accessible. To clear this data, the pointer must also be set to NULL or another value.
Risk
Not resetting pointers can cause dangling pointers. Dangling pointers can cause:
Freeing already freed memory.
Reading from or writing to already freed memory.
Hackers executing code stored in freed pointers or with vulnerable permissions.
Fix
After freeing a pointer, if it is not immediately assigned to another valid address, set the pointer to NULL.
Examples
Result Information
Group: Good Practice |
Language: C | C++ |
Default: Off |
Command-Line Syntax:
MISSING_FREED_PTR_RESET |
Impact: Low |
Version History
Introduced in R2016b
See Also
Use of previously freed pointer
| Invalid free of pointer
| Find
defects (-checkers)
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)