char *next_cr;
next_cr = memchr(start, '\n', buf + size - start);
- next_null = memchr(start, '\0', buf + size - start);
+ next_null = memchr(start, '\0', next_cr?
+ next_cr - start : buf + size - start);
if (!next_cr && !next_null)
break;
- if (next_cr && next_null) {
- end = next_cr < next_null? next_cr : next_null;
- } else if (next_null) {
+ if (next_null)
end = next_null;
- } else
+ else
end = next_cr;
num_lines++;
if (!(flags & FELF_DISCARD_FIRST) || start != buf) {