diff --git a/include/libtorrent/aux_/file_progress.hpp b/include/libtorrent/aux_/file_progress.hpp index 22cc0d32c..ba7bf2825 100644 --- a/include/libtorrent/aux_/file_progress.hpp +++ b/include/libtorrent/aux_/file_progress.hpp @@ -43,7 +43,7 @@ namespace libtorrent class piece_picker; class file_storage; class alert_manager; -class torrent_handle; +struct torrent_handle; namespace aux { diff --git a/src/bdecode.cpp b/src/bdecode.cpp index 0d1aa96d0..d769fa8c8 100644 --- a/src/bdecode.cpp +++ b/src/bdecode.cpp @@ -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) { diff --git a/src/lazy_bdecode.cpp b/src/lazy_bdecode.cpp index 7878e1cc7..dc7b307b3 100644 --- a/src/lazy_bdecode.cpp +++ b/src/lazy_bdecode.cpp @@ -96,10 +96,12 @@ namespace libtorrent { char const* const orig_start = start; ret.clear(); - if (start == end) return 0; std::vector stack; + if (start == end) + TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof); + stack.push_back(&ret); while (start <= end) { diff --git a/test/test_bdecode.cpp b/test/test_bdecode.cpp index 593ccc05f..2c7525a77 100644 --- a/test/test_bdecode.cpp +++ b/test/test_bdecode.cpp @@ -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()); } diff --git a/test/test_bencoding.cpp b/test/test_bencoding.cpp index e439a61fd..1905b7859 100644 --- a/test/test_bencoding.cpp +++ b/test/test_bencoding.cpp @@ -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()); }