read_piece: handle failure to allocate piece buffer
This commit is contained in:
parent
41bfd41cea
commit
52ccad23b9
|
@ -1014,6 +1014,12 @@ namespace libtorrent
|
||||||
|
|
||||||
boost::shared_ptr<read_piece_struct> rp = boost::make_shared<read_piece_struct>();
|
boost::shared_ptr<read_piece_struct> rp = boost::make_shared<read_piece_struct>();
|
||||||
rp->piece_data.reset(new (std::nothrow) char[piece_size]);
|
rp->piece_data.reset(new (std::nothrow) char[piece_size]);
|
||||||
|
if (!rp->piece_data)
|
||||||
|
{
|
||||||
|
m_ses.alerts().emplace_alert<read_piece_alert>(
|
||||||
|
get_handle(), piece, error_code(boost::system::errc::not_enough_memory, generic_category()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
rp->blocks_left = 0;
|
rp->blocks_left = 0;
|
||||||
rp->fail = false;
|
rp->fail = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue