Two things you never ever want to see in a chunk of (production) C/C++ code:
void someReadFunction(char *buf, size_t buflen)
{
...
pos = -1;
end:
buf[pos] = '\\0';
return pos;
}
And no, the programmer wasn’t advancing buf in the omitted part of the function.