diff --git a/src/LCDDisplay.cpp b/src/LCDDisplay.cpp index 14e5bf1..86db08b 100644 --- a/src/LCDDisplay.cpp +++ b/src/LCDDisplay.cpp @@ -80,8 +80,8 @@ void LCDDisplay::writeLines(std::array lines) { /* writes string to line buffer at given pos*/ void LCDDisplay::writeBuf(uint8_t row, uint8_t col, std::string str) { - // size_t max_copy = std::min(str.size(), sizeof(linebuf[row]) - col - 1); - std::memcpy(&linebuf[row][col], str.c_str(), str.size()); // will overflow + size_t len = std::min(str.size(), sizeof(linebuf[row]) - col); + std::memcpy(&linebuf[row][col], str.c_str(), len); // will overflow } /* hyper optimized buffer flush command, writes whole disp with a single write */