Some of the most common sources of heap corruption include:
- a memory assignment that corrupts the header of an allocated block
- an incorrect argument that's passed to a memory allocation function
- an allocator that made certain assumptions in order to avoid
keeping additional memory to validate information, or
to avoid costly runtime checking
- invalid information that's passed in a request, such as to free()
-
overrun and underrun errors
-
releasing memory
-
using uninitialized or stale pointers
Even the most robust allocator can occasionally fall prey to the above problems.
Let's take a look at the last three items in more detail.