From b6708e87f0148480ac871deac943239f91e1a945 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Wed, 21 Jun 2017 20:50:39 -0500 Subject: [PATCH] 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 --- xs/src/libslic3r/GCodeSender.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/libslic3r/GCodeSender.cpp b/xs/src/libslic3r/GCodeSender.cpp index 26ee37fed..af1f697c9 100644 --- a/xs/src/libslic3r/GCodeSender.cpp +++ b/xs/src/libslic3r/GCodeSender.cpp @@ -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(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 l(this->queue_mutex);