From 33afdc32f981678b91197dac26f2fe4fb136cdf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=20C=C5=93ur?= Date: Wed, 12 Oct 2022 05:52:13 +0800 Subject: [PATCH] fix: "Nullptr with nonzero offset" (#3941) --- libtransmission/inout.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libtransmission/inout.cc b/libtransmission/inout.cc index 7177d9977..b38bf0ab4 100644 --- a/libtransmission/inout.cc +++ b/libtransmission/inout.cc @@ -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)