This vulnerability occurs when a program uses incompatible functions to allocate and free memory. For example, freeing memory with a function that doesn't match the one used to create it, like mixing different memory management systems.
Mismatched memory management happens when allocation and deallocation routines come from incompatible sources. Common examples include trying to free stack-allocated memory with `free()` (which only works for heap memory), or allocating with C's `malloc()` but deallocating with C++'s `delete` operator. These functions manage memory in fundamentally different ways, and swapping them breaks the underlying memory manager's expectations. The consequences range from immediate crashes and data corruption to more severe security issues like memory corruption exploits that could lead to arbitrary code execution. The severity depends on the specific routines involved, the program's memory layout, and whether an attacker can control or influence the mismatched operation.
Impact: Modify MemoryDoS: Crash, Exit, or RestartExecute Unauthorized Code or Commands
Strategy: Libraries or Frameworks
Strategy: Libraries or Frameworks
c++
/* do some work with ptr here /
c++c++
/* do some work with ptr here /
c++c++c++Low