assert(bytes != (size_t)-1);
- /* we'll get a zero size for the nul terminator */
- if (!bytes) {
+ /* we'll get a zero size for the nul terminator, or (size_t) -2
+ * if we've reached the end of the buffer */
+ if (!bytes || bytes == (size_t) -2) {
line_cb(arg, start, end - start);
break;
}