PVS V781: size used before it's checked

memcpy with a negative parameter doesn't look like a great idea.

Change-Id: I3d1a8c224bd288784f068086652a84b2b75fcea8
Reviewed-on: https://review.haiku-os.org/c/1671
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Adrien Destugues 2019-08-01 23:03:42 +02:00 committed by waddlesplash
parent 5e7114c1e4
commit 4534d86d21

View File

@ -300,13 +300,11 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length)
do {
ssize_t bytesRead = min_c(sizeof(in), inline_size - offset);
memcpy(in, extent_data->inline_data + offset, bytesRead);
if (bytesRead != (ssize_t)sizeof(in)) {
if (bytesRead <= 0) {
status = Z_STREAM_ERROR;
break;
}
if (bytesRead <= 0) {
status = Z_STREAM_ERROR;
break;
}
memcpy(in, extent_data->inline_data + offset, bytesRead);
zStream.avail_in = bytesRead;
zStream.next_in = (Bytef*)in;