summaryrefslogtreecommitdiff
path: root/libiberty/cp-demangle.c
diff options
context:
space:
mode:
Diffstat (limited to 'libiberty/cp-demangle.c')
-rw-r--r--libiberty/cp-demangle.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 779b4e763a0..aa78c86dd44 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -192,9 +192,9 @@ static void d_init_info (const char *, int, size_t, struct d_info *);
#else
#ifdef __STDC__
#ifdef __STDC_VERSION__
-#if __STDC_VERSION__ >= 199901L
+#if __STDC_VERSION__ >= 199901L && !__STDC_NO_VLA__
#define CP_DYNAMIC_ARRAYS
-#endif /* __STDC__VERSION >= 199901L */
+#endif /* __STDC_VERSION__ >= 199901L && !__STDC_NO_VLA__ */
#endif /* defined (__STDC_VERSION__) */
#endif /* defined (__STDC__) */
#endif /* ! defined (__GNUC__) */
@@ -1330,8 +1330,14 @@ d_encoding (struct d_info *di, int top_level)
really apply here; this happens when parsing a class
which is local to a function. */
if (dc->type == DEMANGLE_COMPONENT_LOCAL_NAME)
- while (is_fnqual_component_type (d_right (dc)->type))
- d_right (dc) = d_left (d_right (dc));
+ {
+ while (d_right (dc) != NULL
+ && is_fnqual_component_type (d_right (dc)->type))
+ d_right (dc) = d_left (d_right (dc));
+
+ if (d_right (dc) == NULL)
+ dc = NULL;
+ }
}
else
{
@@ -3359,7 +3365,7 @@ d_expression_1 (struct d_info *di)
d_advance (di, 2);
if (peek == 't')
type = cplus_demangle_type (di);
- if (!d_peek_next_char (di))
+ if (!d_peek_char (di) || !d_peek_next_char (di))
return NULL;
return d_make_comp (di, DEMANGLE_COMPONENT_INITIALIZER_LIST,
type, d_exprlist (di, 'E'));
@@ -4761,12 +4767,8 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
typed_name = d_right (typed_name);
if (typed_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG)
typed_name = typed_name->u.s_unary_num.sub;
- if (typed_name == NULL)
- {
- d_print_error (dpi);
- return;
- }
- while (is_fnqual_component_type (typed_name->type))
+ while (typed_name != NULL
+ && is_fnqual_component_type (typed_name->type))
{
if (i >= sizeof adpm / sizeof adpm[0])
{
@@ -4785,6 +4787,11 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
typed_name = d_left (typed_name);
}
+ if (typed_name == NULL)
+ {
+ d_print_error (dpi);
+ return;
+ }
}
/* If typed_name is a template, then it applies to the