RFR: 8345632: [ASAN] memory leak in get_numbered_property_as_sorted_string function [v2]
David Holmes
dholmes at openjdk.org
Fri Dec 6 05:38:39 UTC 2024
On Fri, 6 Dec 2024 04:58:20 GMT, SendaoYan <syan at openjdk.org> wrote:
>> Hi all,
>> This PR fix memory leak problem in get_numbered_property_as_sorted_string function which introduced by [JDK-8342089](https://bugs.openjdk.org/browse/JDK-8342089) when the function get_numbered_property_as_sorted_string `return nullptr`. Free the memory before `return nullptr`, risk is low.
>>
>> Additional testing:
>>
>> - [ ] jtreg tests (include tier1/2/3 etc.) on linux-x64
>> - [ ] jtreg tests (include tier1/2/3 etc.) on linux-aarch64
>
> SendaoYan has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
>
> - Merge branch 'openjdk:master' into jbs8345632
> - 8345632: [ASAN] memory leak in get_numbered_property_as_sorted_string function
src/hotspot/share/classfile/modules.cpp line 732:
> 730: os::free((void*)result);
> 731: return nullptr;
> 732: }
I think it would be slightly better to avoid the strdup in the empty string case:
const char* str = st.as_string();
if (str[0] != 0) {
return os::strdup(str);
} else {
return nullptr;
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22594#discussion_r1872632269
More information about the hotspot-runtime-dev
mailing list