内存错误:CRT detected that the application wrote to memory after end of heap buffer

        今天调试测试代码时,发现在用完了new出来的内存buf后,在执行delete时报错了,具体信息为:

        HEAP_CORRUPTION_DETECTED: after Normal block(#908) at 0x399EC0. CRT detected that the application wrote to memory after end of heap buffer .

        经仔细查阅代码,是new出来的buf操作越界了,导致delete时出现这样的错误。

       一般出现此类情况,都是对new出来的内存非法操作引起的,比如数组越界操作、delete掉的内存没有置NULL导致同一个内存被释放了两次(第二次delete时报错)。


原文地址:https://www.cnblogs.com/jiangu66/p/3165719.html