From 5012ca88ac2b7d63026db039a7b6673143740640 Mon Sep 17 00:00:00 2001 From: sanni Date: Wed, 3 Aug 2022 19:48:12 +0200 Subject: [PATCH] Fix crash --- Cart_Reader/COLV.ino | 8 ++++++-- Cart_Reader/INTV.ino | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Cart_Reader/COLV.ino b/Cart_Reader/COLV.ino index bea4321..a86878b 100644 --- a/Cart_Reader/COLV.ino +++ b/Cart_Reader/COLV.ino @@ -460,7 +460,10 @@ void setCart_COL() { else if (b == 2) { for (byte count_newline = 0; count_newline < 7; count_newline++) { while (1) { - if (myFile.peek() == '\n') { + if (myFile.curPosition() == 0) { + break; + } + else if (myFile.peek() == '\n') { myFile.seekSet(myFile.curPosition() - 1); break; } @@ -469,7 +472,8 @@ void setCart_COL() { } } } - myFile.seekSet(myFile.curPosition() + 2); + if (myFile.curPosition() != 0) + myFile.seekSet(myFile.curPosition() + 2); break; } diff --git a/Cart_Reader/INTV.ino b/Cart_Reader/INTV.ino index 2f026ec..45b31d6 100644 --- a/Cart_Reader/INTV.ino +++ b/Cart_Reader/INTV.ino @@ -859,7 +859,10 @@ void setCart_INTV() { else if (b == 2) { for (byte count_newline = 0; count_newline < 7; count_newline++) { while (1) { - if (myFile.peek() == '\n') { + if (myFile.curPosition() == 0) { + break; + } + else if (myFile.peek() == '\n') { myFile.seekSet(myFile.curPosition() - 1); break; } @@ -868,7 +871,8 @@ void setCart_INTV() { } } } - myFile.seekSet(myFile.curPosition() + 2); + if (myFile.curPosition() != 0) + myFile.seekSet(myFile.curPosition() + 2); break; }