Fix crash in cp_print_value_fields
[external/binutils.git] / gdb / cp-valprint.c
index 3cece92..8feaae0 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for printing C++ values for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2018 Free Software Foundation, Inc.
+   Copyright (C) 1986-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -35,7 +35,7 @@
 #include "language.h"
 #include "extension.h"
 #include "typeprint.h"
-#include "byte-vector.h"
+#include "common/byte-vector.h"
 
 /* Controls printing of vtbl's.  */
 static void
@@ -314,13 +314,14 @@ cp_print_value_fields (struct type *type, struct type *real_type,
                }
              else if (field_is_static (&TYPE_FIELD (type, i)))
                {
-                 struct value *v = NULL;
-
                  TRY
                    {
-                     v = value_static_field (type, i);
-                   }
+                     struct value *v = value_static_field (type, i);
 
+                     cp_print_static_field (TYPE_FIELD_TYPE (type, i),
+                                            v, stream, recurse + 1,
+                                            options);
+                   }
                  CATCH (ex, RETURN_MASK_ERROR)
                    {
                      fprintf_filtered (stream,
@@ -328,10 +329,6 @@ cp_print_value_fields (struct type *type, struct type *real_type,
                                        ex.message);
                    }
                  END_CATCH
-
-                 cp_print_static_field (TYPE_FIELD_TYPE (type, i),
-                                        v, stream, recurse + 1,
-                                        options);
                }
              else if (i == vptr_fieldno && type == vptr_basetype)
                {