Check that last_send buffer is large enough in addition to whether or not we have sent data.

Avoids a crash at reconnect, leaves an error message from printer (currently use M110 0 to get back to a good state)

Fixes #4009
This commit is contained in:
Joseph Lenox 2017-06-21 20:50:39 -05:00
parent 2ee32bb244
commit b6708e87f0

View File

@ -359,7 +359,7 @@ GCodeSender::on_read(const boost::system::error_code& error,
boost::algorithm::trim_left_if(line, !boost::algorithm::is_digit());
size_t toresend = boost::lexical_cast<size_t>(line.substr(0, line.find_first_not_of("0123456789")));
toresend++; // N is 0-based
if (toresend >= this->sent - this->last_sent.size()) {
if (toresend >= this->sent - this->last_sent.size() && toresend < this->last_sent.size()) {
{
boost::lock_guard<boost::mutex> l(this->queue_mutex);