Re: EuCOM : Attn Matt : String Return Value
- Posted by Matt Lewis <matthewwalkerlewis at gmai??com> Oct 08, 2007
- 706 views
Matt Lewis wrote: > > Bernie Ryan wrote: > > > > Matt Lewis wrote: > > > > > > Yeah, all I'm concerned about is the actual data, not the null terminator. > > > > > > > > > Yeah, there should probably be two nulls appended (that's what you're > > > asking, right?). I'm not sure why I didn't do that. It's never been > > > a problem, though. > > > > > > > This may cause intermitent exception errors. > > Remember that your peek_bstr() and peek_unicode() depend on two NULLS. > > I agree that this should be fixed. However, I can confirm that it's not the > culprit in this particular case. > In fact, the allocation routine used allocates an extra 4 bytes, and sets the whole thing to 0 using memset(), so, while it's relying on an implementation detail, it was lucky enough that the implementation detail was protecting it. I suspect that in days long gone, I had originally used allocate_string(), which appends its own null (a *documented* implementation detail, so OK), so I added one to make sure I had a double null. When I switched the allocation, I obviously missed this detail, and got saved by the win32lib routine's paranoia. When I decide on a fix to the w32support.e problem, I'll make sure this is cleaned up along with it. Matt