Always reset unit->input in close_input().
authorChristoph Mallon <christoph.mallon@gmx.de>
Fri, 6 Jul 2012 09:00:46 +0000 (11:00 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Fri, 6 Jul 2012 09:01:41 +0000 (11:01 +0200)
main.c

diff --git a/main.c b/main.c
index 3479451..2b934e7 100644 (file)
--- a/main.c
+++ b/main.c
@@ -191,19 +191,19 @@ static void get_output_name(char *buf, size_t buflen, const char *inputname,
 
 static bool close_input(compilation_unit_t *unit)
 {
-       if (unit->input == NULL || unit->input == stdin)
-               return true;
-
-       if (unit->input_is_pipe) {
-               int res = pclose(unit->input);
-               if (res != EXIT_SUCCESS)
-                       return false;
+       assert(unit->input);
+       bool res;
+       if (unit->input == stdin) {
+               res = true;
+       } else if (unit->input_is_pipe) {
+               res = pclose(unit->input) == EXIT_SUCCESS;
        } else {
                fclose(unit->input);
+               res = true;
        }
        unit->input = NULL;
        unit->name  = NULL;
-       return true;
+       return res;
 }
 
 static void print_error_summary(void)