fix(PIIOByteArray): advance pos by actual bytes read, not requested size
readDevice() did pos += size instead of pos += ret. The clamping on the next line (pos = min(pos, data_->size_s())) masked the issue in practice, but the semantics were wrong. Aligns with writeDevice() which correctly uses pos += rs.size_s().
This commit is contained in:
@@ -62,8 +62,7 @@ ssize_t PIIOByteArray::readDevice(void * read_to, ssize_t size) {
|
||||
if (ret <= 0) return -1;
|
||||
memcpy(read_to, data_->data(pos), ret);
|
||||
// piCout << "readed" << ret;
|
||||
pos += size;
|
||||
if (pos > data_->size_s()) pos = data_->size_s();
|
||||
pos += ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user