diff --git a/src/DHTRoutingTableDeserializer.cc b/src/DHTRoutingTableDeserializer.cc index 87b757a6..63a82c70 100644 --- a/src/DHTRoutingTableDeserializer.cc +++ b/src/DHTRoutingTableDeserializer.cc @@ -196,8 +196,8 @@ void DHTRoutingTableDeserializer::deserialize(const std::string& filename) nodes.push_back(node); } - localNode_ = localNode; - nodes_ = nodes; + localNode_ = std::move(localNode); + nodes_ = std::move(nodes); A2_LOG_INFO("DHT routing table was loaded successfully"); } diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index 7a5da1c3..b2161828 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -289,6 +289,10 @@ void DefaultBtProgressInfoFile::load() pieceLength = ntohl(pieceLength); } + if (pieceLength == 0) { + throw DL_ABORT_EX("piece length must not be 0"); + } + uint64_t totalLength; READ_CHECK(fp, &totalLength, sizeof(totalLength)); if (version >= 1) { diff --git a/src/UriListParser.cc b/src/UriListParser.cc index ca021cb3..7fd2b217 100644 --- a/src/UriListParser.cc +++ b/src/UriListParser.cc @@ -77,7 +77,7 @@ void UriListParser::parseNext(std::vector& uris, Option& op) if (fp_->eof()) { break; } - else if (!fp_) { + else if (!*fp_) { throw DL_ABORT_EX("UriListParser:I/O error."); } else { @@ -102,7 +102,7 @@ void UriListParser::parseNext(std::vector& uris, Option& op) if (fp_->eof()) { return; } - else if (!fp_) { + else if (!*fp_) { throw DL_ABORT_EX("UriListParser:I/O error."); } }