Fix memory corruption in C++ demangler

The __cxa_demangle_gnu3() and cpp_demangle_gnu3() functions segfault on
various libcxxabi test cases due to a copy and paste error. This change
fixes that.

This is a subset of https://github.com/libcxxrt/libcxxrt/pull/34 which
fixes the immediate problem.

Reviewed by: imp, emaste (I think)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1222
This commit is contained in:
Justine Tunney 2024-05-09 19:55:45 -06:00 committed by Warner Losh
parent fbe965591f
commit 12be6f12e8
2 changed files with 2 additions and 2 deletions

View File

@ -2138,7 +2138,7 @@ cpp_demangle_read_sname(struct cpp_demangle_data *ddata)
assert(ddata->cur_output->size > 0);
if (vector_read_cmd_find(&ddata->cmd, READ_TMPL) == NULL)
ddata->last_sname =
ddata->cur_output->container[ddata->output.size - 1];
ddata->cur_output->container[ddata->cur_output->size - 1];
ddata->cur += len;

View File

@ -2472,7 +2472,7 @@ cpp_demangle_read_sname(struct cpp_demangle_data *ddata)
assert(ddata->cur_output->size > 0);
if (vector_read_cmd_find(&ddata->cmd, READ_TMPL) == NULL)
ddata->last_sname =
ddata->cur_output->container[ddata->output.size - 1];
ddata->cur_output->container[ddata->cur_output->size - 1];
ddata->cur += len;