[PATCH 10/18] output.c: Fix potential NULL pointer dereferences

Tim Hentenaar <[email protected]> Sat, 4 Jul 2015 13:43:24 +0200
Newsgroups gmane.comp.gnu.indent.bugs
Message-ID <[email protected]>
Signed-off-by: Tim Hentenaar <[email protected]>
---
 src/output.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/output.c b/src/output.c
index bc66c7b..9346495 100644
--- a/src/output.c
+++ b/src/output.c
@@ -545,17 +545,15 @@ static void set_next_buf_break (
         }
 
         xfree(buf_break);
+        if (!bb) goto ret;
 
         /* Set buf_break to first break in the list */
-
         buf_break = bb;
 
         /* GDB_HOOK_buf_break */
-
         buf_break->prev = NULL;
 
         /* Find a better break of the existing breaks */
-
         for (bb = buf_break; bb; bb = bb->next)
         {
             if (bb->col > settings.max_col)
@@ -580,6 +578,9 @@ static void set_next_buf_break (
             }
         }
     }
+
+ret:
+	return;
 }
 
 /**
@@ -1363,7 +1364,7 @@ extern void close_output(
         else
         {
 #ifdef PRESERVE_MTIME
-            if (file_stats != NULL)
+            if (file_stats != NULL && filename)
             {
                 struct utimbuf buf;
 
-- 
2.3.6