diff options
author | Petr Machata <pmachata@redhat.com> | 2012-10-30 00:25:50 +0100 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2012-10-30 00:25:50 +0100 |
commit | bc58f2a1b2b516b2176a4a32117065dde4813734 (patch) | |
tree | 828756b01653cd98a52e1182931d64f393ea4ea4 /output.c | |
parent | 3299797320059f659f3abb80f3ce02bab3db8bb9 (diff) | |
download | ltrace-bc58f2a1b2b516b2176a4a32117065dde4813734.tar.gz |
Proper ownership tracking of types used for parameter pack expansion
This plugs a leak.
Diffstat (limited to 'output.c')
-rw-r--r-- | output.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -254,17 +254,17 @@ output_error(void) static int fetch_simple_param(enum tof type, Process *proc, struct fetch_context *context, - struct value_dict *arguments, struct arg_type_info *info, + struct value_dict *arguments, + struct arg_type_info *info, int own, struct value *valuep) { /* Arrays decay into pointers per C standard. We check for * this here, because here we also capture arrays that come * from parameter packs. */ - int own = 0; if (info->type == ARGTYPE_ARRAY) { struct arg_type_info *tmp = malloc(sizeof(*tmp)); if (tmp != NULL) { - type_init_pointer(tmp, info, 0); + type_init_pointer(tmp, info, own); tmp->lens = info->lens; info = tmp; own = 1; @@ -318,12 +318,15 @@ fetch_param_pack(enum tof type, Process *proc, struct fetch_context *context, if (insert_stop) fetch_param_stop(arguments, params_leftp); - if (info->type == ARGTYPE_VOID) + if (info->type == ARGTYPE_VOID) { + type_destroy(info); + free(info); break; + } struct value val; if (fetch_simple_param(type, proc, context, arguments, - info, &val) < 0) + info, 1, &val) < 0) goto fail; int stop = 0; @@ -353,7 +356,7 @@ fetch_one_param(enum tof type, Process *proc, struct fetch_context *context, int rc; case PARAM_FLAVOR_TYPE: return fetch_simple_param(type, proc, context, arguments, - param->u.type.type, NULL); + param->u.type.type, 0, NULL); case PARAM_FLAVOR_PACK: if (fetch_param_pack_start(context, |