more fix, less crash

This commit is contained in:
Jonathan Bennett 2025-06-27 18:16:14 -05:00
parent d33303a038
commit 8190211b90

View File

@ -133,7 +133,7 @@ void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisp
uint8_t effectiveLineHeight = FONT_HEIGHT_SMALL - 3;
uint8_t visibleTotalLines = std::min<uint8_t>(totalLines, (screenHeight - vPadding * 2) / effectiveLineHeight);
uint8_t linesShown = lineCount;
const char *linePointers[visibleTotalLines]; // this is sort of a dynamic allocation
const char *linePointers[visibleTotalLines + 1] = {0}; // this is sort of a dynamic allocation
// copy the linestarts to display to the linePointers holder
for (int i = 0; i < lineCount; i++) {
@ -186,8 +186,7 @@ void NotificationRenderer::drawNotificationBox(OLEDDisplay *display, OLEDDisplay
is_picker = true;
// seelction box
while (lineCount < totalLines) {
if (lines[lineCount] != nullptr) {
while (lines[lineCount] != nullptr) {
auto newlinePointer = strchr(lines[lineCount], '\n');
if (newlinePointer)
lineLengths[lineCount] = (newlinePointer - lines[lineCount]); // Check for newlines first
@ -200,9 +199,6 @@ void NotificationRenderer::drawNotificationBox(OLEDDisplay *display, OLEDDisplay
maxWidth = lineWidths[lineCount];
}
lineCount++;
} else {
break;
}
}
// count lines