fix: "Nullptr with nonzero offset" (#3941)

This commit is contained in:
A Cœur 2022-10-12 05:52:13 +08:00 committed by GitHub
parent 4f957657d1
commit 33afdc32f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -211,7 +211,10 @@ int readOrWritePiece(tr_torrent* tor, IoMode io_mode, tr_block_info::Location lo
uint64_t const bytes_this_pass = std::min(uint64_t{ buflen }, uint64_t{ tor->fileSize(file_index) - file_offset });
err = readOrWriteBytes(tor->session, tor, io_mode, file_index, file_offset, buf, bytes_this_pass);
buf += bytes_this_pass;
if (buf != nullptr)
{
buf += bytes_this_pass;
}
buflen -= bytes_this_pass;
if (err != 0 && io_mode == IoMode::Write && tor->error != TR_STAT_LOCAL_ERROR)