Merge elftoolchain r3877 (by jkoshy):
Incorporate fixes from Dimitry Andric: - Use a BUFFER_GROW() macro to avoid rounding errors in capacity calculations. - Fix a bug introduced in [r3531]. - Fix handling of nested template parameters. Ticket: #581 This should fix a number of assertions on elftoolchain's cxxfilt, and allow it to correctly demangle several names that it could not handle before. Obtained from: https://sourceforge.net/p/elftoolchain/code/3877/ PR: 250702 MFC after: 3 days
This commit is contained in:
parent
740a82fa8a
commit
dc2273365b
@ -56,6 +56,7 @@ struct vector_str {
|
||||
};
|
||||
|
||||
#define BUFFER_GROWFACTOR 1.618
|
||||
#define BUFFER_GROW(x) (((x)+0.5)*BUFFER_GROWFACTOR)
|
||||
|
||||
#define ELFTC_FAILURE 0
|
||||
#define ELFTC_ISDIGIT(C) (isdigit((C) & 0xFF))
|
||||
|
@ -2135,10 +2135,10 @@ cpp_demangle_read_sname(struct cpp_demangle_data *ddata)
|
||||
if (err == 0)
|
||||
return (0);
|
||||
|
||||
assert(ddata->output.size > 0);
|
||||
assert(ddata->cur_output->size > 0);
|
||||
if (vector_read_cmd_find(&ddata->cmd, READ_TMPL) == NULL)
|
||||
ddata->last_sname =
|
||||
ddata->output.container[ddata->output.size - 1];
|
||||
ddata->cur_output->container[ddata->output.size - 1];
|
||||
|
||||
ddata->cur += len;
|
||||
|
||||
@ -2421,7 +2421,7 @@ cpp_demangle_read_tmpl_args(struct cpp_demangle_data *ddata)
|
||||
return (0);
|
||||
|
||||
limit = 0;
|
||||
v = &ddata->output;
|
||||
v = ddata->cur_output;
|
||||
for (;;) {
|
||||
idx = v->size;
|
||||
if (!cpp_demangle_read_tmpl_arg(ddata))
|
||||
@ -3909,7 +3909,7 @@ vector_read_cmd_push(struct vector_read_cmd *v, enum read_cmd cmd, void *data)
|
||||
return (0);
|
||||
|
||||
if (v->size == v->capacity) {
|
||||
tmp_cap = v->capacity * BUFFER_GROWFACTOR;
|
||||
tmp_cap = BUFFER_GROW(v->capacity);
|
||||
if ((tmp_r_ctn = malloc(sizeof(*tmp_r_ctn) * tmp_cap)) == NULL)
|
||||
return (0);
|
||||
for (i = 0; i < v->size; ++i)
|
||||
@ -3974,7 +3974,7 @@ vector_type_qualifier_push(struct vector_type_qualifier *v,
|
||||
return (0);
|
||||
|
||||
if (v->size == v->capacity) {
|
||||
tmp_cap = v->capacity * BUFFER_GROWFACTOR;
|
||||
tmp_cap = BUFFER_GROW(v->capacity);
|
||||
if ((tmp_ctn = malloc(sizeof(enum type_qualifier) * tmp_cap))
|
||||
== NULL)
|
||||
return (0);
|
||||
|
@ -152,7 +152,7 @@ vector_str_grow(struct vector_str *v)
|
||||
|
||||
assert(v->capacity > 0);
|
||||
|
||||
tmp_cap = v->capacity * BUFFER_GROWFACTOR;
|
||||
tmp_cap = BUFFER_GROW(v->capacity);
|
||||
|
||||
assert(tmp_cap > v->capacity);
|
||||
|
||||
@ -253,7 +253,7 @@ vector_str_push_vector_head(struct vector_str *dst, struct vector_str *org)
|
||||
if (dst == NULL || org == NULL)
|
||||
return (false);
|
||||
|
||||
tmp_cap = (dst->size + org->size) * BUFFER_GROWFACTOR;
|
||||
tmp_cap = BUFFER_GROW(dst->size + org->size);
|
||||
|
||||
if ((tmp_ctn = malloc(sizeof(char *) * tmp_cap)) == NULL)
|
||||
return (false);
|
||||
@ -293,7 +293,7 @@ vector_str_push_vector(struct vector_str *dst, struct vector_str *org)
|
||||
if (dst == NULL || org == NULL)
|
||||
return (false);
|
||||
|
||||
tmp_cap = (dst->size + org->size) * BUFFER_GROWFACTOR;
|
||||
tmp_cap = BUFFER_GROW(dst->size + org->size);
|
||||
|
||||
if ((tmp_ctn = malloc(sizeof(char *) * tmp_cap)) == NULL)
|
||||
return (false);
|
||||
|
Loading…
Reference in New Issue
Block a user