minor robustness improvement

If seg.name is at least 32 characters long, strncpy will fill the 32-byte window without appending '\0'. This could lead to sporadic errors.
This commit is contained in:
Frank
2025-11-07 11:58:55 +01:00
parent 9115cd17af
commit c58c6ef268

View File

@@ -111,6 +111,7 @@ byte renderImageToSegment(Segment &seg) {
if (strncmp(lastFilename +1, seg.name, 32) != 0) { // segment name changed, load new image
strncpy(lastFilename +1, seg.name, 32);
lastFilename[33] = '\0'; // make sure that lastFilename is always null-terminated
gifDecodeFailed = false;
size_t fnameLen = strlen(lastFilename);
if ((fnameLen < 4) || strcmp(lastFilename + fnameLen - 4, ".gif") != 0) { // empty segment name, name too short, or name not ending in .gif