From ed95a42091a5013d42881d8c430ff1320de61b91 Mon Sep 17 00:00:00 2001 From: Jorj Bauer Date: Fri, 22 Jan 2021 22:09:16 -0500 Subject: [PATCH] fix crasher when there are exactly 10 names to show --- bios.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bios.cpp b/bios.cpp index 916b941..8a11064 100644 --- a/bios.cpp +++ b/bios.cpp @@ -752,6 +752,8 @@ uint16_t BIOS::SelectFileScreenHandler(bool needsRedraw, bool performAction) localRedraw = true; } else if (selectedMenuItem == BIOS_MAXFILES+1) { + // FIXME what if there are no files on the next page? We + // shouldn't show a blank page. if (fileCount == BIOS_MAXFILES) { // don't let them select // 'Next' if there were no // files in the list or if the @@ -1185,7 +1187,7 @@ uint16_t BIOS::DrawDiskNames(uint8_t page, int8_t selection, const char *filter) name); vpos += LINEHEIGHT; - if (strlen(fileDirectory[i]) > 39) { + if (strlen(name) > 39) { // Break the string at 39 characters and start drawing the second line indented more char restOfString[BIOS_MAXPATH-39+1]; strcpy(restOfString, (char *)&name[39]); @@ -1200,8 +1202,9 @@ uint16_t BIOS::DrawDiskNames(uint8_t page, int8_t selection, const char *filter) vpos += LINEHEIGHT; } - if (i >= fileCount) + if (i+1 >= fileCount) { endsHere = true; + } } vpos += LINEHEIGHT/2;