This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Fix a (one shot small) leak in language.c
- From: Tom Tromey <tom at tromey dot com>
- To: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 05 Dec 2018 11:06:21 -0700
- Subject: Re: [RFA] Fix a (one shot small) leak in language.c
- References: <20181204224802.8846-1-philippe.waroquiers@skynet.be>
>>>>> "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:
Philippe> It is unclear why a xstrdup-ed value is assigned to 'language'
Philippe> at initialization time, while a static "auto" string is assigned
Philippe> as part of the set_language_command.
git annotate shows it is ancient, so it's hard to say -- maybe things
were different back then or maybe it's just an ancient bug.
Philippe> * language.c (_initialize_language): Fix leak by assigning
Philippe> a static string to language. Same for range and case_sensitive,
Philippe> even if no leak is detected for these variables.
I think technically the value should come from the array passed to
add_setshow_enum_cmd, but in practice that only matters if the values
are compared using ==, which is not the case here; and in any case the
current way (comparing using strcmp) seems more clear and thus
preferable.
So, this is ok. Thanks.
Tom