fritz-tools: fix segfault in caldata-extract

* Fix incorrect error message in case input file opening fails
 * Don't close files in case the pointers are invalid

Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
David Bauer 2023-02-28 19:53:44 +01:00
parent 19817fa3f5
commit 7662700613
2 changed files with 6 additions and 4 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fritz-tools
PKG_RELEASE:=1
PKG_RELEASE:=2
CMAKE_INSTALL:=1
include $(INCLUDE_DIR)/package.mk

View File

@ -210,7 +210,7 @@ int main(int argc, char **argv)
if (argc > 1 && optind <= argc) {
in = fopen(argv[optind], "r");
if (!in) {
perror("Failed to create output file");
perror("Failed to open input file");
goto out_bad;
}
}
@ -253,7 +253,9 @@ out_bad:
ret = EXIT_FAILURE;
out:
fclose(in);
fclose(out);
if (in)
fclose(in);
if (out)
fclose(out);
return ret;
}