浏览代码

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 <[email protected]>
David Bauer 2 年之前
父节点
当前提交
7662700613
共有 2 个文件被更改,包括 6 次插入4 次删除
  1. 1 1
      package/utils/fritz-tools/Makefile
  2. 5 3
      package/utils/fritz-tools/src/fritz_cal_extract.c

+ 1 - 1
package/utils/fritz-tools/Makefile

@@ -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

+ 5 - 3
package/utils/fritz-tools/src/fritz_cal_extract.c

@@ -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;
 }