I think this is wrong. If `sizeLeft` is 1 at the beginning of this loop, we'll add the `delim`, then try to add another byte, which will cause sprintf_s to return a negative number, indicating failure.