* src/rmdir.c (main): Only inspect the returned stat structure, when stat(2) returns success. --- src/rmdir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/rmdir.c b/src/rmdir.c index 149d4659a..c6e2aba0f 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -262,7 +262,8 @@ main (int argc, char **argv) struct stat st; int ret = stat (dir, &st); /* Some other issue following, or is actually a directory. */ - if ((ret != 0 && errno != ENOTDIR) || S_ISDIR (st.st_mode)) + if ((ret != 0 && errno != ENOTDIR) + || (ret == 0 && S_ISDIR (st.st_mode))) { /* Ensure the last component was a symlink. */ char* dir_arg = xstrdup (dir); -- 2.26.2