Monday 12 July 2010

Memory corruption in Stile

Trying to find a mem corruption bug from Stile. It's quite difficult with DevC++ (gcc), because gdb is not very good at catching errors. I may have to re-create a Visual C++ project for Stile to find the bug. Another option is refactor some shit and hope for the best. In worst case the bug has existed for a long time in some part of the source code. I guess it's about time to find out where it is.

The bug was a trailing zero type. strlen() returns the length without the trailing zero so you need to add it to the buffer given to strcpy which copies also the trailing zero to destination.

2 comments:

Jotaf said...

Weeeell, since you're using C++, can't you replace c-strings with the standard string class? In those rare cases when you need a c-string, you can still get it through the c_str() member function. But yeah, epic bug hunt!

Krice said...

I feel that std::string is too heavy for small stuff, but I'm using it more often now.