RFR: JDK-8304684: Memory leak in DirectivesParser::set_option_flag [v2]
Dean Long
dlong at openjdk.org
Tue Mar 21 22:32:43 UTC 2023
On Tue, 21 Mar 2023 20:34:17 GMT, Justin King <jcking at openjdk.org> wrote:
>> Add missing `FREE_C_HEAP_ARRAY` call.
>
> Justin King has updated the pull request incrementally with one additional commit since the last revision:
>
> Update based on review
>
> Signed-off-by: Justin King <jcking at google.com>
Changes requested by dlong (Reviewer).
src/hotspot/share/compiler/directivesParser.cpp line 351:
> 349: }
> 350:
> 351: FREE_C_HEAP_ARRAY(char, s);
This looks unsafe. We shouldn't free the memory without clearing all references to it, otherwise there is a dangling pointer. There is already another reference to the memory because of this call:
`(set->*test)((void *)&s);` (see the set_function_definition macro)
I think it would be better to move this copying call until after validation has been done.
-------------
PR Review: https://git.openjdk.org/jdk/pull/13125#pullrequestreview-1351476419
PR Review Comment: https://git.openjdk.org/jdk/pull/13125#discussion_r1144052137
More information about the hotspot-compiler-dev
mailing list