RFR: 8354453: Don't strcpy in os::strdup, use memcpy instead [v2]
Anton Artemov
duke at openjdk.org
Fri Apr 25 12:38:10 UTC 2025
On Fri, 25 Apr 2025 11:07:09 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
>> Anton Artemov 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 remote-tracking branch 'origin/master' into JDK-8354453
>> - 8354453: Don't strcpy in os::strdup, use memcpy instead
>
> src/hotspot/share/runtime/os.cpp line 600:
>
>> 598: if (dup_str == nullptr) return nullptr;
>> 599: memcpy(dup_str, str, size);
>> 600: *(dup_str + size) = '\0';
>
> Just `memcpy(dup_str, str, size + 1)` ?
I guess the actual performance difference is next to zero, but cleaner code is better, addressed in the latest commit.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24651#discussion_r2060160080
More information about the hotspot-runtime-dev
mailing list