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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user