From 749420308ec232709711dd849cd9d51a804bc838 Mon Sep 17 00:00:00 2001 From: mucor Date: Thu, 29 Apr 2021 16:52:13 +0800 Subject: [PATCH] fix:shell cmd rm -r crash when open target dir failed Change-Id: I1146ab12b02aeef3f9a2a0422ee45936f5e4c105 --- fs/vfs/vfs_cmd/vfs_shellcmd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/vfs/vfs_cmd/vfs_shellcmd.c b/fs/vfs/vfs_cmd/vfs_shellcmd.c index 0c95699e..29aa4bd0 100644 --- a/fs/vfs/vfs_cmd/vfs_shellcmd.c +++ b/fs/vfs/vfs_cmd/vfs_shellcmd.c @@ -837,6 +837,10 @@ static int os_shell_cmd_do_rmdir(const char *pathname) return remove(pathname); } d = opendir(pathname); + if (d == NULL) + { + return -1; + } while (1) { dirent = readdir(d);