diff --git a/src/Platform/RepRap.cpp b/src/Platform/RepRap.cpp index 0d8199927f..b88e33225a 100644 --- a/src/Platform/RepRap.cpp +++ b/src/Platform/RepRap.cpp @@ -2327,7 +2327,10 @@ OutputBuffer *RepRap::GetThumbnailResponse(const char *filename, FilePosition of } // Check for end of thumbnail. We'd like to use a regex here but we can't afford the flash space of a regex parser in some build configurations. - if (StringStartsWith(p, "thumbnail end") || StringStartsWith(p, "thumbnail_QOI end")|| StringStartsWith(p, "thumbnail_JPG end")) + if ( StringStartsWith(p, "thumbnail end") || StringStartsWith(p, "thumbnail_QOI end")|| StringStartsWith(p, "thumbnail_JPG end") + // Also stop if the base64 data has ended, to avoid sending to the end of file if the end marker is missing. We don't want to take too long so just look for space. + || strchr(p, ' ') != nullptr + ) { offset = 0; break;