Archive for the ‘Guest Posts’ Category

A nasty string initialization bug in C

Sunday, August 7th, 2011

Today I encountered a bug that was quite difficult to find regarding strings. In order for strings to work they must be null-terminated, and this implies that an array of characters can contain a string with a length equal to the array size minus one, because there must be space for the null character. I found out that, when initializing array of chars with strings, the compiler does not complain if just the null character doesn’t fit.

(more…)

  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Slashdot
  • Reddit
  • Technorati
  • StumbleUpon
  • Twitter