web_peer_connection: make a copy of the request before calling incomi… (#1091)

web_peer_connection: make a copy of the request before calling incoming_piece
This commit is contained in:
Steven Siloti 2016-09-14 09:29:07 -07:00 committed by Arvid Norberg
parent 22043fd186
commit 0759b732c1
1 changed files with 8 additions and 1 deletions

View File

@ -979,8 +979,15 @@ void web_peer_connection::incoming_payload(char const* buf, int len)
, front_request.piece, front_request.start, front_request.length);
#endif
incoming_piece(front_request, &m_piece[0]);
// Make a copy of the request and pop it off the queue before calling
// incoming_piece because that may lead to a call to disconnect()
// which will clear the request queue and invalidate any references
// to the request
peer_request const front_request_copy = front_request;
m_requests.pop_front();
incoming_piece(front_request_copy, &m_piece[0]);
m_piece.clear();
}
}