Run-Time Check Failure #2 – Stack around the variable ‘hexByte’ was corrupted

If you are going to develop any game or decoder then you may experience this error. Today when i am developing an ASN decoder for our company i faced the error below:

Run-Time Check Failure #2 – Stack around the variable ‘hexByte’ was corrupted.

To develop my decoder first i need to develop a turbo C program. Then convert this code into a DLL. When i am calling the dll function from my C# windows application I found this error. The screenshot is given below:


Basically for example this will happen if you are going to write to an invalid address. Mostly this comes from something like this:

char hexByte[5];
hexByte[6] = 'E';

Then when you leave from function scope system will freeing the variable hexbyte then system will prompt this error that the variable is corrupted because you wrote to an invalid address.

So check the variable that is stated in your error message & increase the size of the array will resolve your problem.

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code