Commit 542ccaaf authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Better handle very long C++ qualified identifiers in dwarf.

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: 's avatarEric Pouech <epouech@codeweavers.com>
parent 0db9f33b
...@@ -1177,7 +1177,10 @@ static const char* dwarf2_get_cpp_name(dwarf2_debug_info_t* di, const char* name ...@@ -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) if (!di->unit_ctx->cpp_name)
{
di->unit_ctx->cpp_name = pool_alloc(&di->unit_ctx->pool, MAX_SYM_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; last = di->unit_ctx->cpp_name + MAX_SYM_NAME - strlen(name) - 1;
strcpy(last, name); strcpy(last, name);
...@@ -1194,7 +1197,11 @@ static const char* dwarf2_get_cpp_name(dwarf2_debug_info_t* di, const char* 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); size_t len = strlen(diname.u.string);
last -= 2 + len; 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); memcpy(last, diname.u.string, len);
last[len] = last[len + 1] = ':'; last[len] = last[len + 1] = ':';
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment