1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-20 18:56:39 +02:00

split: avoid NULL + 1

* src/split.c (lines_chunk_split): Don’t add to a null pointer.
It’s undefined behavior, and it’s unnecessarily confusing
regardless.
This commit is contained in:
Paul Eggert
2021-09-15 13:44:46 -07:00
parent ed1c58427d
commit f8dc5a6215

View File

@@ -921,8 +921,11 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
/* Begin looking for '\n' at last byte of chunk. */
off_t skip = MIN (n_read, MAX (0, chunk_end - n_written));
char *bp_out = memchr (bp + skip, eolchar, n_read - skip);
if (bp_out++)
next = true;
if (bp_out)
{
bp_out++;
next = true;
}
else
bp_out = eob;
to_write = bp_out - bp;