forked from premiere/premiere-libtorrent
fixed some error handling in lazy_bdecode to handle out-of-memory errors
This commit is contained in:
parent
31a56af1ad
commit
7412931183
|
@ -96,6 +96,7 @@ release 0.14.8
|
|||
* force_recheck() no longer crashes on torrents with no metadata
|
||||
* fixed broadcast socket regression from 0.14.7
|
||||
* fixed hang in NATPMP when shut down while waiting for a response
|
||||
* fixed some more error handling in bdecode
|
||||
|
||||
release 0.14.7
|
||||
|
||||
|
|
|
@ -47,10 +47,10 @@ namespace
|
|||
|
||||
namespace libtorrent
|
||||
{
|
||||
int fail_bdecode(lazy_entry& ret)
|
||||
int fail_bdecode(lazy_entry& ret, int return_value = -1)
|
||||
{
|
||||
ret.clear();
|
||||
return -1;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
// fills in 'val' with what the string between start and the
|
||||
|
@ -110,10 +110,11 @@ namespace libtorrent
|
|||
start = parse_int(start, end, ':', len);
|
||||
if (start == 0 || start + len + 3 > end || *start != ':') return fail_bdecode(ret);
|
||||
++start;
|
||||
if (start == end) fail_bdecode(ret);
|
||||
if (start == end) return fail_bdecode(ret);
|
||||
lazy_entry* ent = top->dict_append(start);
|
||||
if (ent == 0) return fail_bdecode(ret, -2);
|
||||
start += len;
|
||||
if (start >= end) fail_bdecode(ret);
|
||||
if (start >= end) return fail_bdecode(ret);
|
||||
stack.push_back(ent);
|
||||
t = *start;
|
||||
++start;
|
||||
|
@ -128,6 +129,7 @@ namespace libtorrent
|
|||
continue;
|
||||
}
|
||||
lazy_entry* ent = top->list_append();
|
||||
if (ent == 0) return fail_bdecode(ret, -2);
|
||||
stack.push_back(ent);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue