http://bugs.winehq.org/show_bug.cgi?id=28857
--- Comment #16 from Charles Davis cdavis@mymail.mines.edu 2011-10-23 16:33:03 CDT --- (In reply to comment #15)
Created attachment 37089 [details] additional debug log
The last lengths seem interesting.
According to the log you posted, it is indeed stepping past the end of the buffer as I suspected.
What compiler are you using to compile Wine? A small test program I made based on this code runs just fine with GCC 4.2 in my FreeBSD VM.