On 11/6/20 6:34 PM, Jeff Law wrote:
So you XNEWVEC and store the result into "merge_decoded_options".  But
you free "decoded_options".  Was that intentional?

Hello.

Good point here.


This seems to bring a bit more predictability, but I suspect there's
more to do here.

Yes, both should be freed. One can see the following leak on master:

==12237== 176 bytes in 1 blocks are definitely lost in loss record 669 of 786
==12237==    at 0x483BD7B: realloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12237==    by 0x1AB10CD: xrealloc (xmalloc.c:179)
==12237==    by 0x1A1AE59: prune_options (opts-common.c:1139)
==12237==    by 0x1A1AE59: decode_cmdline_options_to_array(unsigned int, char 
const**, unsigned int, cl_decoded_option**, unsigned int*) (opts-common.c:1027)
==12237==    by 0xDCD456: decode_cmdline_options_to_array_default_mask(unsigned 
int, char const**, cl_decoded_option**, unsigned int*) (opts-global.c:273)
==12237==    by 0x921377: parse_optimize_options(tree_node*, bool) 
(c-common.c:5709)
==12237==    by 0x9768DB: handle_optimize_attribute(tree_node**, tree_node*, 
tree_node*, int, bool*) (c-attribs.c:4962)
==12237==    by 0x84596A: decl_attributes(tree_node**, tree_node*, int, 
tree_node*) (attribs.c:723)
==12237==    by 0x856F88: c_decl_attributes(tree_node**, tree_node*, int) 
(c-decl.c:5043)
==12237==    by 0x8661E5: start_function(c_declspecs*, c_declarator*, 
tree_node*) (c-decl.c:9408)
==12237==    by 0x8D644A: c_parser_declaration_or_fndef(c_parser*, bool, bool, bool, 
bool, bool, tree_node**, vec<c_token, va_heap, vl_ptr>, bool, tree_node*, 
oacc_routine_data*, bool*) (c-parser.c:2444)
==12237==    by 0x8DF343: c_parser_external_declaration(c_parser*) 
(c-parser.c:1777)
==12237==    by 0x8DFE41: c_parser_translation_unit (c-parser.c:1650)
==12237==    by 0x8DFE41: c_parse_file() (c-parser.c:21876)

Martin

Reply via email to