@@ -1131,7 +1131,7 @@ class MetadataReader {
1131
1131
Demangle::NodePointer
1132
1132
buildContextMangling (ContextDescriptorRef descriptor,
1133
1133
Demangler &dem) {
1134
- auto demangling = buildContextDescriptorMangling (descriptor, dem);
1134
+ auto demangling = buildContextDescriptorMangling (descriptor, dem, 50 );
1135
1135
if (!demangling)
1136
1136
return nullptr ;
1137
1137
@@ -2104,9 +2104,13 @@ class MetadataReader {
2104
2104
2105
2105
Demangle::NodePointer
2106
2106
buildContextDescriptorMangling (const ParentContextDescriptorRef &descriptor,
2107
- Demangler &dem) {
2107
+ Demangler &dem, int recursion_limit) {
2108
+ if (recursion_limit <= 0 ) {
2109
+ return nullptr ;
2110
+ }
2111
+
2108
2112
if (descriptor.isResolved ()) {
2109
- return buildContextDescriptorMangling (descriptor.getResolved (), dem);
2113
+ return buildContextDescriptorMangling (descriptor.getResolved (), dem, recursion_limit - 1 );
2110
2114
}
2111
2115
2112
2116
// Try to demangle the symbol name to figure out what context it would
@@ -2124,7 +2128,11 @@ class MetadataReader {
2124
2128
2125
2129
Demangle::NodePointer
2126
2130
buildContextDescriptorMangling (ContextDescriptorRef descriptor,
2127
- Demangler &dem) {
2131
+ Demangler &dem, int recursion_limit) {
2132
+ if (recursion_limit <= 0 ) {
2133
+ return nullptr ;
2134
+ }
2135
+
2128
2136
// Read the parent descriptor.
2129
2137
auto parentDescriptorResult = readParentContextDescriptor (descriptor);
2130
2138
@@ -2141,7 +2149,7 @@ class MetadataReader {
2141
2149
Demangle::NodePointer parentDemangling = nullptr ;
2142
2150
if (auto parentDescriptor = *parentDescriptorResult) {
2143
2151
parentDemangling =
2144
- buildContextDescriptorMangling (parentDescriptor, dem);
2152
+ buildContextDescriptorMangling (parentDescriptor, dem, recursion_limit - 1 );
2145
2153
if (!parentDemangling && !demangledParentNode)
2146
2154
return nullptr ;
2147
2155
}
0 commit comments