Update src/graphics/draw/NodeListRenderer.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Ben Meadors 2025-10-25 07:12:46 -05:00 committed by GitHub
parent 7640caa053
commit 78ee8b1d37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -91,8 +91,14 @@ const char *getSafeNodeName(OLEDDisplay *display, meshtastic_NodeInfoLite *node)
nodeName[strlen(nodeName) - 1] = '\0'; nodeName[strlen(nodeName) - 1] = '\0';
} }
// If we actually truncated, append "..." // If we actually truncated, append "..." (ensure space remains in buffer)
if (strlen(nodeName) < origLen) { if (strlen(nodeName) < origLen) {
size_t len = strlen(nodeName);
size_t maxLen = sizeof(nodeName) - 4; // 3 for "..." and 1 for '\0'
if (len > maxLen) {
nodeName[maxLen] = '\0';
len = maxLen;
}
strcat(nodeName, "..."); strcat(nodeName, "...");
} }
} }