Heap corruption: What could the cause be?

后端 未结 13 1456
时光取名叫无心
时光取名叫无心 2020-12-25 12:56

I am investigating a crash due to heap corruption. As this issue is non-trivial and involves analyzing the stack and dump results, I have decided to do a code review of file

13条回答
  •  一生所求
    2020-12-25 13:42

    Common scenarios include:

    • Writing outside the allocated space of an array (char *stuff = new char[10]; stuff[10] = 3;)
    • Casting to the wrong type
    • Uninitialized pointers
    • Typo error for -> and .
    • Typo error when using * and & (or multiple of either)

    [EDIT] From the comments, a few more:

    • Mixing new [] and new with delete [] and delete
    • Missing or incorrect copy-constructors
    • Pointer pointing to garbage
    • Calling delete multiple times on the same data
    • Polymorphic baseclasses without virtual destructors

提交回复
热议问题