VariantIncomplete
CWE-761Free of Pointer not at Start of Buffer
Category: memory
Description
The product calls free() on a pointer to a memory resource that was allocated on the heap, but the pointer is not at the start of the buffer.
Common consequences· 1
- Integrity / Availability / Confidentiality — Modify Memory, DoS: Crash, Exit, or Restart, Execute Unauthorized Code or Commands
Potential mitigations· 4
- [Implementation]When utilizing pointer arithmetic to traverse a buffer, use a separate variable to track progress through memory and preserve the originally allocated address for later freeing.
- [Implementation]When programming in C++, consider using smart pointers provided by the boost library to help correctly and consistently manage memory.
- [Architecture and Design]
- [Architecture and Design]Use a language that provides abstractions for memory allocation and deallocation.
References
Related by meaning· 6
Nearest entities by semantic similarity across the cs-graph corpus.