Release of Invalid Pointer or Reference |
Weakness ID: 763 (Weakness Base) | Status: Incomplete |
Description Summary
Extended Description
This weakness can take several forms, such as:
1. The memory was allocated, explicitly or implicitly, via one memory management method and deallocated using a different, non-compatible function (CWE-762).
2. The function calls or memory management routines chosen are appropriate, however they are used incorrectly, such as in CWE-761.
Phase: Implementation Only call matching memory management functions. Do not mix and match routines. For example, when you allocate a buffer with malloc(), dispose of the original pointer with free(). |
Phase: Implementation When programming in C++, consider using smart pointers provided by the boost library to help correctly and consistently manage memory. |
Phases: Implementation; Operation Use a library that contains built-in protection against free of invalid pointers, such as glibc. |
Phase: Architecture and Design Use a language that provides abstractions for memory allocation and deallocation. |
Phase: Testing Use a tool that dynamically detects memory management problems, such as valgrind. |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 399 | Resource Management Errors | Development Concepts (primary)699 |
ChildOf | ![]() | 404 | Improper Resource Shutdown or Release | Research Concepts (primary)1000 |
ChildOf | ![]() | 633 | Weaknesses that Affect Memory | Resource-specific Weaknesses (primary)631 |
ParentOf | ![]() | 761 | Free of Pointer not at Start of Buffer | Research Concepts (primary)1000 |
ParentOf | ![]() | 762 | Mismatched Memory Management Routines | Research Concepts (primary)1000 |
"boost C++ Library Smart Pointers". <http://www.boost.org/doc/libs/1_38_0/libs/smart_ptr/smart_ptr.htm>. |
"Valgrind". <http://valgrind.org/>. |
This area of the view CWE-1000 hierarchy needs additional work. Several entries will likely be created in this branch. Currently the focus is on free() of memory, but delete and other related release routines may require the creation of intermediate entries that are not specific to a particular function. In addition, the role of other types of invalid pointers, such as an expired pointer, i.e. CWE-415 Double Free and release of uninitialized pointers, related to CWE-457. |