From b5e717ffe085ea94775a38eb936c48ab649375c5 Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 3 Dec 2019 12:45:13 +0100 Subject: [PATCH] back-port ut_pex fixes --- src/ut_pex.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index 96bc06404..db55a8d35 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -350,12 +350,12 @@ namespace libtorrent { namespace { } } - bdecode_node p6 = pex_msg.dict_find("dropped6"); -#ifndef TORRENT_DISABLE_LOGGING - if (p6) num_dropped += p6.string_length() / 18; -#endif - if (p6.type() == bdecode_node::string_t) + bdecode_node p6 = pex_msg.dict_find_string("dropped6"); + if (p6) { +#ifndef TORRENT_DISABLE_LOGGING + num_dropped += p6.string_length() / 18; +#endif int const num_peers = p6.string_length() / 18; char const* in = p6.string_ptr(); @@ -368,14 +368,12 @@ namespace libtorrent { namespace { } } - p6 = pex_msg.dict_find("added6"); + p6 = pex_msg.dict_find_string("added6"); #ifndef TORRENT_DISABLE_LOGGING if (p6) num_added += p6.string_length() / 18; #endif - bdecode_node const p6f = pex_msg.dict_find("added6.f"); - if (p6.type() == bdecode_node::string_t - && p6f.type() == bdecode_node::string_t - && p6f.string_length() == p6.string_length() / 18) + bdecode_node const p6f = pex_msg.dict_find_string("added6.f"); + if (p6 && p6f && p6f.string_length() == p6.string_length() / 18) { int const num_peers = p6f.string_length(); char const* in = p6.string_ptr();