Browse Source

[2.0.x] Fix null check in lsDive (#10978)

Giuliano 6 years ago
parent
commit
e970e429b6
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      Marlin/src/sd/cardreader.cpp

+ 2
- 2
Marlin/src/sd/cardreader.cpp View File

@@ -110,8 +110,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
110 110
       createFilename(dosFilename, p);
111 111
 
112 112
       // Allocate enough stack space for the full path to a folder, trailing slash, and nul
113
-      bool prepend_is_empty = (prepend[0] == '\0');
114
-      int len = (prepend_is_empty ? 1 : strlen(prepend)) + strlen(dosFilename) + 1 + 1;
113
+      const bool prepend_is_empty = (!prepend || prepend[0] == '\0');
114
+      const int len = (prepend_is_empty ? 1 : strlen(prepend)) + strlen(dosFilename) + 1 + 1;
115 115
       char path[len];
116 116
 
117 117
       // Append the FOLDERNAME12/ to the passed string.

Loading…
Cancel
Save