uncrustify (0.56-2) 01_check_for_null_to_prevent_segmentation_fault.diff

Summary

 src/combine.cpp |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

    
download this patch

Patch contents

Description: Check for NULL to prevent a segmentation fault.
Author: Ben Gardner <gardner.ben@gmail.com>

--- a/src/combine.cpp
+++ b/src/combine.cpp
@@ -1676,10 +1676,13 @@ static void fix_typedef(chunk_t *start)
        (next->type != CT_STRUCT) &&
        (next->type != CT_UNION))
    {
-      /* We have just a regular typedef */
-      LOG_FMT(LTYPEDEF, "%s: regular typedef [%.*s] on line %d\n", __func__,
-              the_type->len, the_type->str, the_type->orig_line);
-      the_type->flags |= PCF_ANCHOR;
+      if (the_type != NULL)
+      {
+         /* We have just a regular typedef */
+         LOG_FMT(LTYPEDEF, "%s: regular typedef [%.*s] on line %d\n", __func__,
+                 the_type->len, the_type->str, the_type->orig_line);
+         the_type->flags |= PCF_ANCHOR;
+      }
       return;
    }