RFR: 8281384: Random chars on paste from Windows clipboard [v8]
Kevin Rushforth
kcr at openjdk.org
Mon Mar 31 17:04:17 UTC 2025
On Fri, 28 Mar 2025 15:10:46 GMT, Oliver Schmidtmer <oschmidtmer at openjdk.org> wrote:
>> Windows programs may reuse a clipboard buffer that is larger than the new content. In this case de NUL terminator is not at the end of the buffer, but within it.
>> The current implementation copys the whole buffer into a text field, including the NUL terminator and the remaining chars.
>>
>> The JIRA ticket contains a JNA based sample program, which prefills the buffer for demonstrating this issue.
>> If this should be added as a unit test, I'm open for advice how to do that.
>
> Oliver Schmidtmer 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 nine additional commits since the last revision:
>
> - revert to original mime types
> - Merge remote-tracking branch 'remotes/origin/master' into JDK-8281384
> - readding flavors with changed mapping
> - remove non unicode textformats
> - format and unneeded var removed
> - cleanup
> - search NUL terminator in native code
> - check both UTF16 bytes
> - JDK-8281384: Random chars on paste from Windows clipboard
The latest version looks good to me. I tested it and it works as expected.
I left a suggestion and minor formatting comment. Will reapprove if you make changes.
modules/javafx.graphics/src/main/native-glass/win/GlassClipboard.cpp line 410:
> 408: jbyte *pos = me.getMem() + i;
> 409: if (*(pos) == 0 && *(pos + 1) == 0){
> 410: cdata = i;
Suggestion: Although the loop will terminate as currently coded, it might be clearer to add an explicit "break;" here.
Minor: add a space between the `)` and `{` on lines 407 and 409.
-------------
Marked as reviewed by kcr (Lead).
PR Review: https://git.openjdk.org/jfx/pull/1724#pullrequestreview-2729879366
PR Review Comment: https://git.openjdk.org/jfx/pull/1724#discussion_r2021379918
More information about the openjfx-dev
mailing list