C中错误的malloc导致程序崩溃
我的程序在第二次运行时在此线路上崩溃:C中错误的malloc导致程序崩溃,c,windows,malloc,C,Windows,Malloc,我的程序在第二次运行时在此线路上崩溃: char* temp_directive = (char *)malloc(7); 出现此错误时: Critical error detected c0000374 Windows has triggered a breakpoint in Maman14.exe. This may be due to a corruption of the heap, which indicates a bug in Maman14.exe or
char* temp_directive = (char *)malloc(7);
出现此错误时:
Critical error detected c0000374
Windows has triggered a breakpoint in Maman14.exe.
This may be due to a corruption of the heap, which indicates a bug in Maman14.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while Maman14.exe has focus.
我不明白为什么,它总是发生在第二轮。
我尝试添加免费(临时指令),但没有帮助
有人知道这个问题吗?
听起来您在代码的前面运行了数组的末尾,在您尝试malloc该内存空间之前,内存管理不会拾取它。发现问题,它是由不同的realloc引起的。谢谢大家 你能给我们看一下完整的代码吗?这几乎可以肯定是由于先前的
空闲
或超出内存范围的写入造成的。运行valgrind查看它发生在哪里。在malloc
之后,您使用temp\u指令做什么?很多操作系统在指针返回以启用内务管理之前会存储一些信息。也许你把管家搞砸了?密码很长。。这就是为什么我没有添加它。我在malloc之后检查null,但是崩溃发生在malloc期间。我很确定这与影响第二个malloc的第一次分配有关