merge bdecode patch from RC_1_0. an empty string now produces an error rather than an empty bdecoded struct
This commit is contained in:
parent
3dda8f97d6
commit
52b4aed466
|
@ -43,7 +43,7 @@ namespace libtorrent
|
|||
class piece_picker;
|
||||
class file_storage;
|
||||
class alert_manager;
|
||||
class torrent_handle;
|
||||
struct torrent_handle;
|
||||
|
||||
namespace aux
|
||||
{
|
||||
|
|
|
@ -713,7 +713,9 @@ namespace libtorrent
|
|||
stack_frame* stack = TORRENT_ALLOCA(stack_frame, depth_limit);
|
||||
|
||||
char const* const orig_start = start;
|
||||
if (start == end) return 0;
|
||||
|
||||
if (start == end)
|
||||
TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);
|
||||
|
||||
while (start <= end)
|
||||
{
|
||||
|
|
|
@ -96,10 +96,12 @@ namespace libtorrent
|
|||
{
|
||||
char const* const orig_start = start;
|
||||
ret.clear();
|
||||
if (start == end) return 0;
|
||||
|
||||
std::vector<lazy_entry*> stack;
|
||||
|
||||
if (start == end)
|
||||
TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);
|
||||
|
||||
stack.push_back(&ret);
|
||||
while (start <= end)
|
||||
{
|
||||
|
|
|
@ -568,7 +568,8 @@ TORRENT_TEST(empty_string)
|
|||
bdecode_node e;
|
||||
error_code ec;
|
||||
int ret = bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
TEST_EQUAL(ret, 0);
|
||||
TEST_EQUAL(ret, -1);
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof));
|
||||
printf("%s\n", print_entry(e).c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -439,7 +439,9 @@ TORRENT_TEST(bencoding)
|
|||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
TEST_EQUAL(ret, 0);
|
||||
TEST_EQUAL(ret, -1);
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof
|
||||
, get_bdecode_category()));
|
||||
printf("%s\n", print_entry(e).c_str());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue