forked from premiere/premiere-libtorrent
fix segfault in put_data
If less than three nodes are found to put an item to then traversal_algorithm::start will add router nodes. This leads to a crash in put_data::invoke when it tries to read a token from uninitialized memory in a null_observer.
This commit is contained in:
parent
adb70a8dc3
commit
9f7aa7f3a6
|
@ -58,6 +58,7 @@ struct put_data: traversal_algorithm
|
|||
put_data(node& node, put_callback const& callback);
|
||||
|
||||
virtual char const* name() const;
|
||||
virtual void start();
|
||||
|
||||
void set_data(item const& data) { m_data = data; }
|
||||
|
||||
|
|
|
@ -47,6 +47,14 @@ put_data::put_data(node& dht_node, put_callback const& callback)
|
|||
|
||||
char const* put_data::name() const { return "put_data"; }
|
||||
|
||||
void put_data::start()
|
||||
{
|
||||
// router nodes must not be added to puts
|
||||
init();
|
||||
bool is_done = add_requests();
|
||||
if (is_done) done();
|
||||
}
|
||||
|
||||
void put_data::set_targets(std::vector<std::pair<node_entry, std::string> > const& targets)
|
||||
{
|
||||
for (std::vector<std::pair<node_entry, std::string> >::const_iterator i = targets.begin()
|
||||
|
|
Loading…
Reference in New Issue