yanglint BUGFIX freeing output handler on print command
checking for content of output handler had a side effect of printing
error message when the stdout was not inserted and some external
filepath was used. S othere is a need of a flag if the default stdout
was used or there is a filepath-based output handler which need cleanup.
diff --git a/tools/lint/cmd_print.c b/tools/lint/cmd_print.c
index badf9b1..f112beb 100644
--- a/tools/lint/cmd_print.c
+++ b/tools/lint/cmd_print.c
@@ -68,6 +68,7 @@
const char *node_path = NULL;
LYS_OUTFORMAT format = LYS_OUT_TREE;
struct ly_out *out = NULL;
+ ly_bool out_stdout = 0;
if (parse_cmdline(cmdline, &argc, &argv)) {
goto cleanup;
@@ -133,6 +134,7 @@
YLMSG_E("Could not use stdout to print output.\n");
goto cleanup;
}
+ out_stdout = 1;
}
if (node_path) {
@@ -185,5 +187,5 @@
cleanup:
free_cmdline(argv);
- ly_out_free(out, NULL, ly_out_file(out, NULL) != stdout ? 1 : 0);
+ ly_out_free(out, NULL, out_stdout ? 0 : 1);
}