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 0f1a39b30c507e5a775e6dfa538e74716645e165..e4902d9c9a11744bd993be9908bb28ef9f0b1108 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;