cli: prevent segfault if input file failed to open
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 27 Oct 2015 12:42:00 +0000 (13:42 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 27 Oct 2015 12:42:00 +0000 (13:42 +0100)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
main.c

diff --git a/main.c b/main.c
index 0f1a39b..e4902d9 100644 (file)
--- a/main.c
+++ b/main.c
@@ -444,7 +444,7 @@ out:
        if (jsobj)
                json_object_put(jsobj);
 
-       if (input != stdin)
+       if (input && input != stdin)
                fclose(input);
 
        return rv;