diff options
author | jaseg <git@jaseg.net> | 2020-12-25 13:42:09 +0100 |
---|---|---|
committer | jaseg <git@jaseg.net> | 2020-12-25 13:42:09 +0100 |
commit | 9efc71de4f4be9c43c0521dd5f627bbdcc82b78a (patch) | |
tree | c2e785908db8692e6fe664fdff8d14ec949dc468 | |
parent | 5b97d040b303a8e4761ed76661ab880fbcd099fb (diff) | |
download | lolcat-9efc71de4f4be9c43c0521dd5f627bbdcc82b78a.tar.gz lolcat-9efc71de4f4be9c43c0521dd5f627bbdcc82b78a.tar.bz2 lolcat-9efc71de4f4be9c43c0521dd5f627bbdcc82b78a.zip |
Fix incorrect usage of ferror after fclose
Closes #35
-rw-r--r-- | lolcat.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1,4 +1,4 @@ -/* Copyright (C) 2014 jaseg <github@jaseg.net> +/* Copyright (C) 2020 jaseg <github@jaseg.net> * * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE * Version 2, December 2004 @@ -205,10 +205,14 @@ int main(int argc, char** argv) cc = -1; if (f) { - fclose(f); - if (ferror(f)) { fwprintf(stderr, L"Error reading input file \"%s\": %s\n", *filename, strerror(errno)); + fclose(f); + return 2; + } + + if (fclose(f)) { + fwprintf(stderr, L"Error closing input file \"%s\": %s\n", *filename, strerror(errno)); return 2; } } |