From: Paul Eggert Date: Wed, 15 Sep 2021 20:44:46 +0000 (-0700) Subject: split: avoid NULL + 1 X-Git-Tag: v9.0~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8dc5a6215846f289d9e9c4c18a7c51f008f76d3;p=thirdparty%2Fcoreutils.git 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. --- diff --git a/src/split.c b/src/split.c index f653e1b85b..6062f052a1 100644 --- a/src/split.c +++ b/src/split.c @@ -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;