Quote Originally Posted by matsp View Post
I would also add an assert(buflen >= 0) (or if-statement with a printout, or similar) just above the line with the cast [if there are several casts on the same (unchanged) variable, you obviously only need one assert]. That way, _IF_ the bufLen is ever negative, you have a chance to catch it.

Yeah, I guess since assert() only aborts in debug builds it should be safe to add it. I'll probably do that. I don't know if anyone on that team ever tests using debug builds though.