Only completeWrite() if we didn't run off the end of the buffer.

If we did run off the end, complain about it.
This commit is contained in:
Oliver Jowett 2014-12-08 20:17:48 +00:00
parent 39d905324f
commit c712543ee5

View file

@ -1196,7 +1196,11 @@ static void writeFATSV() {
}
p += snprintf(p, bufsize(p,end), "\n");
completeWrite(&Modes.fatsv_out, p);
if (p <= end)
completeWrite(&Modes.fatsv_out, p);
else
fprintf(stderr, "fatsv: output too large (max %d, overran by %d)\n", TSV_MAX_PACKET_SIZE, (int) (p - end));
# undef bufsize
a->fatsv_last_emitted = now;