简体   繁体   English

由于C中的malloc错误导致程序崩溃

[英]program crash due to bad malloc in C

my program is crashing on the second run on this line: 我的程序在第二次运行时崩溃:

   char* temp_directive = (char *)malloc(7);

with this error: 有这个错误:

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.

I can't understand why, it always happen on the second run. 我无法理解为什么,它总是发生在第二轮。 I've tried to add free(temp_directive), but it didn't help 我试图添加免费(temp_directive),但它没有帮助

anyone famailer with this issue? 谁有这个问题?

http://blogs.msdn.com/b/jiangyue/archive/2010/03/16/windows-heap-overrun-monitoring.aspx http://blogs.msdn.com/b/jiangyue/archive/2010/03/16/windows-heap-overrun-monitoring.aspx

Sounds like you ran off the end of the array earlier in the code, and your memory management isn't picking it up until you try to malloc that memory space. 听起来好像你在代码中早先在数组的末尾运行了,并且在你尝试malloc那个内存空间之前你的内存管理没有把它拿起来。

Found the problem, it was caused from a different realloc . 发现问题,它是由不同的realloc引起的。 Thanks everyone! 感谢大家!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM