From e970e429b64bc6b6314e7f96b293db87097a79d8 Mon Sep 17 00:00:00 2001
From: Giuliano <3684609+GMagician@users.noreply.github.com>
Date: Sun, 10 Jun 2018 05:03:49 +0200
Subject: [PATCH] [2.0.x] Fix null check in lsDive (#10978)

---
 Marlin/src/sd/cardreader.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp
index 53de807c28..159086c82e 100644
--- a/Marlin/src/sd/cardreader.cpp
+++ b/Marlin/src/sd/cardreader.cpp
@@ -110,8 +110,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
       createFilename(dosFilename, p);
 
       // Allocate enough stack space for the full path to a folder, trailing slash, and nul
-      bool prepend_is_empty = (prepend[0] == '\0');
-      int len = (prepend_is_empty ? 1 : strlen(prepend)) + strlen(dosFilename) + 1 + 1;
+      const bool prepend_is_empty = (!prepend || prepend[0] == '\0');
+      const int len = (prepend_is_empty ? 1 : strlen(prepend)) + strlen(dosFilename) + 1 + 1;
       char path[len];
 
       // Append the FOLDERNAME12/ to the passed string.
-- 
GitLab