RFR: 8345632: [ASAN] memory leak in get_numbered_property_as_sorted_string function [v2]

SendaoYan syan at openjdk.org
Fri Dec 6 09:09:38 UTC 2024


On Fri, 6 Dec 2024 05:39:30 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> 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;
>> }
>
> Or slightly cleaner:
> 
> return (st.size() > 0)  ? os::strdup(st.as_string()) : nullptr;

Thanks David, avoid strdup in the empty string case also make ASAN silently, thanks.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22594#discussion_r1872889402


More information about the hotspot-runtime-dev mailing list