Hi, Please find attached the proposed patch for Bug 69687: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69687
* Limiting the length of the mangled string to 264k characters. * Limiting the loop iterations to 256 (max. of C++ function parameters). --- a/libiberty/cplus-dem.c +++ b/libiberty/cplus-dem.c @@ -847,6 +847,13 @@ char * cplus_demangle (const char *mangled, int options) { + /** Limit the maximum length of mangled. + * C++ Std, Annex B (Implementation quantities): + * - Number of characters in an internal identifier or macro name [1 024]. + * - Arguments in one function call [256]. */ + if (mangled && strlen (mangled) > 263168) + return xstrdup (mangled); + char *ret; struct work_stuff work[1]; @@ -4488,6 +4495,8 @@ { return (0); } + /* C++ Standard Annex B: Parameters in one function definition [256].*/ + if (r > 256) r = 256; while (work->nrepeats > 0 || --r >= 0) { tem = work -> typevec[t]; Best regards, - Marcel