浏览代码

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

Giuliano 7 年前
父节点
当前提交
e970e429b6
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2
    2
      Marlin/src/sd/cardreader.cpp

+ 2
- 2
Marlin/src/sd/cardreader.cpp 查看文件

@@ -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.

正在加载...
取消
保存