diff
20      if (err >= limit)
21 +        if ((br + bpr*sy) < br_end)  // Assuming br_end is the end of the buffer
22              rows[nrows++] = br + bpr*sy;
