Browse Source

Fix range check bug in FileList::seek() (#13286)

When `count()` returns 0, `pos > (count()-1)` will always yield `true` due to integer underflow.
Tobias Frost 6 years ago
parent
commit
57afd0ab37
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      Marlin/src/lcd/extensible_ui/ui_api.cpp

+ 1
- 1
Marlin/src/lcd/extensible_ui/ui_api.cpp View File

@@ -688,7 +688,7 @@ namespace ExtUI {
688 688
 
689 689
   bool FileList::seek(const uint16_t pos, const bool skip_range_check) {
690 690
     #if ENABLED(SDSUPPORT)
691
-      if (!skip_range_check && pos > (count() - 1)) return false;
691
+      if (!skip_range_check && (pos + 1) > count()) return false;
692 692
       const uint16_t nr =
693 693
         #if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
694 694
           count() - 1 -

Loading…
Cancel
Save