VC Critical error detected c0000374 crash problem and solution

Phenomenon:
The specific scenario is detected in New allocated memory, and the VS output information is: Critical Error Detected C0000374 is normal on X64, X86 is crashed
This occurs when memory is allocated, but this is the kernel-mode address area, which the heap manager cannot specify. So it’s clear that the heap data has been tampered with by overflow, which is heap corruption. The next step is to find out where the data overflow is occurring.
Analysis:
Debug looks at the normal allocation of memory, generally this is caused by the array out of bounds.
If not this time, then probably the last time the memory assignment crossed the line, causing the heap to break.
Solutions:
Find the location of the last memory allocation in the code, add 1 to the length, normal. Problem solving.
Int Buflen = 100;
_PRTA(unsigned char,ScaleBuf,Buflen + 1); //
Here is the smart pointer used; Unsigned char (unsigned char) does not need to store the end char. In theory, it does not need to add 1.
 
Conclusion:
In this case, basically the memory assignment is out of bounds, so let’s see if this is the case in the code above;
1. Memory allocation is short 1, 2. Memory assignment is out of bounds and the length is over. Such as memset ();


Read More: