how to fix buffer overrun

I keep getting the massage saying that " A buffer overrun has been detected which has corrupted  the program's internal state. The program cannot safely continue execution and must now be terminated". How can I fix that problem? I'm not really good with computer so you need to show me every step clearly. Thank you.
havannguyenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

itsmeandnobodyelseCommented:
First you must locate the issue in the source code. Easiest would be if the overrun occured in debug mode as well. Then, the debugger would throw an assertion and you could check the call stack to find out where the overrun had occured. It often is a strcpy or memcpy. It also could be a loop writing beyond buffer boundaries.

if it happens in release mode only it is more difficult. You could call a log function (don't forgot to flush each message or open and close the logfile with each call) at begin of each function and at end. After the termination check your logfile and you know in which function the crash happened. Then, narrow the logs until you finally have located the statement. Post it here if you don't know why it crashes.
0
BarsMonsterCommented:
You'd better replace all old-school functions like strcpy with safe ones like strcpy_n  which aredesigned specifically to reduce that kind of errors. Also, you may replace all your arrays and dynamic memory with STL data structures. You'd better dig around STL, very nice and productive thing.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.