fritz-tools: fix segfault in caldata-extract
authorDavid Bauer <mail@david-bauer.net>
Tue, 28 Feb 2023 18:53:44 +0000 (19:53 +0100)
committerDavid Bauer <mail@david-bauer.net>
Thu, 2 Mar 2023 16:04:28 +0000 (17:04 +0100)
 * 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>
package/utils/fritz-tools/Makefile
package/utils/fritz-tools/src/fritz_cal_extract.c

index a4d69bdf719a81be9990b8967ac1d4eb47c15051..6e20b56ff8a7cab56d87edfc09f06ab5eeec90cc 100644 (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
index 8156dfd1a79cabd633d2ad2ce0364567f8f4c46f..2978d86e0cc48ef205a1fd5fcfc8576bbb00d2a6 100644 (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;
 }