This fixes some crashes especially when dealing with very long C++ names (like template classes).
Fortunately, dwarf internals don't require type lookup by name (eg. on forward declaration), so the impact of thrashing some names is limited.
It's very likely native doesn't store directly these very long names (it could either store the qualified mangled name - which can be way shorter for template classes - or use the names in lexical hierarchy: both boil down to storing less information, and recompute it (unmangle or class hierarchy walk) upon request). But this would need a proper C++ support in dbghelp. Not for today.
Signed-off-by: Eric Pouech epouech@codeweavers.com
From: Eric Pouech epouech@codeweavers.com
This fixes some crashes especially when dealing with very long C++ names (like template classes).
Fortunately, dwarf internals don't require type lookup by name (eg. on forward declaration), so the impact of thrashing some names is limited.
It's very likely native doesn't store directly these very long names (it could either store the qualified mangled name - which can be way shorter for template classes - or use the names in lexical hierarchy: both boil down to storing less information, and recompute it (unmangle or class hierarchy walk) upon request). But this would need a proper C++ support in dbghelp. Not for today.
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/dwarf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index 1402ffcb941..46da2968dbb 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -1177,7 +1177,10 @@ static const char* dwarf2_get_cpp_name(dwarf2_debug_info_t* di, const char* name }
if (!di->unit_ctx->cpp_name) + { di->unit_ctx->cpp_name = pool_alloc(&di->unit_ctx->pool, MAX_SYM_NAME); + if (!di->unit_ctx->cpp_name) return name; + } last = di->unit_ctx->cpp_name + MAX_SYM_NAME - strlen(name) - 1; strcpy(last, name);
@@ -1194,7 +1197,11 @@ static const char* dwarf2_get_cpp_name(dwarf2_debug_info_t* di, const char* name { size_t len = strlen(diname.u.string); last -= 2 + len; - if (last < di->unit_ctx->cpp_name) return NULL; + if (last < di->unit_ctx->cpp_name) + { + WARN("Too long C++ qualified identifier for %s... using unqualified identifier\n", name); + return name; + } memcpy(last, diname.u.string, len); last[len] = last[len + 1] = ':'; }