!203 fix rm -r crash when opendir failed

Merge pull request !203 from 野生毛霉君/master
This commit is contained in:
openharmony_ci 2021-04-29 19:07:04 +08:00 committed by Gitee
commit c1b2b3c73e
1 changed files with 4 additions and 0 deletions

View File

@ -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);