size_t bytes_read = 0;
size_t bytes_written = 0;
- while (len - bytes_read >= 0) {
+ while (bytes_read < len) {
// Find the first marker byte in the rest of the stream.
const uint8_t* ptr = memchr(src, MARKER_CHAR, len - bytes_read);
if (ptr == NULL) {