summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authortrippels <trippels@138bc75d-0d04-0410-961f-82ee72b054a4>2017-03-08 14:28:38 +0000
committertrippels <trippels@138bc75d-0d04-0410-961f-82ee72b054a4>2017-03-08 14:28:38 +0000
commita664c62cf916d036dba3d25973e5bb92c523536e (patch)
tree1d24f195851c031e0d3f5a1d72300583d1befa25 /include
parent673716e32919303c4bc3e4d13b6633ce8d9d3df2 (diff)
downloadgcc-a664c62cf916d036dba3d25973e5bb92c523536e.tar.gz
Fix PR demangler/70909 and 67264 (endless demangler recursion)
ChangeLog: PR demangler/70909 PR demangler/67264 * include/demangle.h: Add d_printing to struct demangle_component and pass struct demangle_component as non const. libiberty/ChangeLog: PR demangler/70909 PR demangler/67264 * cp-demangle.c: Fix endless recursion. Pass struct demangle_component as non const. (d_make_empty): Initialize variable. (d_print_comp_inner): Limit recursion. (d_print_comp): Decrement variable. * cp-demint.c (cplus_demangle_fill_component): Initialize variable. (cplus_demangle_fill_builtin_type): Likewise. (cplus_demangle_fill_operator): Likewise. * testsuite/demangle-expected: Add tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245978 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'include')
-rw-r--r--include/demangle.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/demangle.h b/include/demangle.h
index 7cc955dc28d..996203b2d78 100644
--- a/include/demangle.h
+++ b/include/demangle.h
@@ -494,6 +494,11 @@ struct demangle_component
/* The type of this component. */
enum demangle_component_type type;
+ /* Guard against recursive component printing.
+ Initialize to zero. Private to d_print_comp.
+ All other fields are final after initialization. */
+ int d_printing;
+
union
{
/* For DEMANGLE_COMPONENT_NAME. */
@@ -688,7 +693,7 @@ cplus_demangle_v3_components (const char *mangled, int options, void **mem);
extern char *
cplus_demangle_print (int options,
- const struct demangle_component *tree,
+ struct demangle_component *tree,
int estimated_length,
size_t *p_allocated_size);
@@ -708,7 +713,7 @@ cplus_demangle_print (int options,
extern int
cplus_demangle_print_callback (int options,
- const struct demangle_component *tree,
+ struct demangle_component *tree,
demangle_callbackref callback, void *opaque);
#ifdef __cplusplus