Previously, any line buffered write of size 0 would cause an error. The variable used to track the index of the last newline started at the size of the write - 1, which underflowed. Now it's handled properly, and a test has been added to prevent regressions. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D127914