ls: abort a directory if we cannot opendir it
We should not try and perform operations on an invalid DIR* stream. Instead, we shall let the error message be printed, and the return code set (existing behaviour) and abort afterwards.
This commit is contained in:
parent
e92a1aef54
commit
46495ea902
1
ls.c
1
ls.c
|
@ -250,6 +250,7 @@ lsdir(const char *path, const struct entry *dir)
|
||||||
if (!(dp = opendir(dir->name))) {
|
if (!(dp = opendir(dir->name))) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
weprintf("opendir %s%s:", path, dir->name);
|
weprintf("opendir %s%s:", path, dir->name);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (chdir(dir->name) < 0)
|
if (chdir(dir->name) < 0)
|
||||||
eprintf("chdir %s:", dir->name);
|
eprintf("chdir %s:", dir->name);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user