derf / feh

a fast and light image viewer
https://feh.finalrewind.org
Other
1.53k stars 159 forks source link

ResourceLeak in src/filelist.c? #730

Closed schsiung closed 10 months ago

schsiung commented 10 months ago

I have checked the source code with infer, it seems there is a Resource Leak in src/filelist.c:182.

src/filelist.c:182: error: Resource Leak
  resource of type `_IO_FILE` acquired by call to `fdopen()` at line 172, column 12 is not released after line 182, column 9.
  180.  while ((readsize = fread(buf, sizeof(char), sizeof(buf), stdin)) > 0) {
  181.      if (fwrite(buf, sizeof(char), readsize, outfile) < readsize) {
  182.          free(sfn);
               ^
  183.          return;
  184.      }

I suppose it's better to call fclose(outfile); even the some errors happen when writing the file.

derf commented 10 months ago

Yup. Thanks!