tail: avoid theoretically undefined behavior
authorJim Meyering <meyering@redhat.com>
Wed, 28 Dec 2011 17:30:50 +0000 (18:30 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 28 Dec 2011 17:53:32 +0000 (18:53 +0100)
commit6e00315bf290310895036fce979a7e0210871b63
tree1a6f6861b0a7bac8d08dae7d3f72d085d256d2bf
parent3e7a1473ae41440bd5e8b62f0532ac99a112f7bd
tail: avoid theoretically undefined behavior

* src/tail.c (start_lines): Do not form potentially-invalid address.
Use safe_read's return value as a pointer offset only after
ensuring that it is not SAFE_READ_ERROR (size_t)(-1).
Spotted by coverity.
Also, move declaration of "p" to be closer to first use.
src/tail.c