diff --git a/src/sudo_edit.c b/src/sudo_edit.c index 9c83b0266..8679f7e2e 100644 --- a/src/sudo_edit.c +++ b/src/sudo_edit.c @@ -384,8 +384,10 @@ sudo_edit_open_nonwritable(char *path, int oflags, mode_t mode, * writable directories. */ is_writable = dir_is_writable(dfd, &user_details, command_details); - if (is_writable == -1) + if (is_writable == -1) { + close(dfd); debug_return_int(-1); + } while (path[0] == '/') path++;