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