Skip to content

Commit

Permalink
Bugfix: don't compare files against logfile_status when log file not …
Browse files Browse the repository at this point in the history
…open.
  • Loading branch information
adrianlopezroche committed Sep 4, 2022
1 parent 3133902 commit 99bc907
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fdupes.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ int grokdir(char *dir, file_t **filelistp, struct stat *logfile_status)
}

/* ignore logfile */
if (info.st_dev == logfile_status->st_dev && info.st_ino == logfile_status->st_ino)
if (logfile_status != 0 && info.st_dev == logfile_status->st_dev && info.st_ino == logfile_status->st_ino)
{
free(newfile->d_name);
free(newfile);
Expand Down Expand Up @@ -1468,16 +1468,16 @@ int main(int argc, char **argv) {

/* F_RECURSE is not set for directories before --recurse: */
for (x = optind; x < firstrecurse; x++)
filecount += grokdir(argv[x], &files, &logfile_status);
filecount += grokdir(argv[x], &files, logfile ? &logfile_status : 0);

/* Set F_RECURSE for directories after --recurse: */
SETFLAG(flags, F_RECURSE);

for (x = firstrecurse; x < argc; x++)
filecount += grokdir(argv[x], &files, &logfile_status);
filecount += grokdir(argv[x], &files, logfile ? &logfile_status : 0);
} else {
for (x = optind; x < argc; x++)
filecount += grokdir(argv[x], &files, &logfile_status);
filecount += grokdir(argv[x], &files, logfile ? &logfile_status : 0);
}

if (!files) {
Expand Down

0 comments on commit 99bc907

Please sign in to comment.