Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8304441

[macos] Crash when putting invalid unicode char on clipboard

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • jfx21
    • jfx11, jfx20, 8, jfx17, jfx21
    • javafx
    • Mac / x64 running macOS 13.1 (Ventura)
      Mac / aarch64 running macOS 12.5.1 (Monterey)

    Backports

      Description

        Putting an invalid unicode character on the system clipboard will cause the application to crash with an assertion error. The following is sufficient to provoke the crash:

                int[] codePoints = { 0xD83D };
                String str = new String(codePoints, 0, codePoints.length);
                ClipboardContent c = new ClipboardContent();
                c.put(DataFormat.PLAIN_TEXT, str);
                Clipboard.getSystemClipboard().setContent(c);

        To reproduce, run the attached test program:

        $ java ClipboardCrash

        2023-03-18 06:28:07.771 java[85534:2112820] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Calling -setData:forType: on NSPasteboardItem with nil `data` for type public.utf8-plain-text.'
        *** First throw call stack:
        (
        0 CoreFoundation 0x00007ff80a4db40b __exceptionPreprocess + 242
        1 libobjc.A.dylib 0x00007ff80a027e25 objc_exception_throw + 48
        2 CoreFoundation 0x00007ff80a4db270 +[NSException raise:format:] + 214
        3 AppKit 0x00007ff80d8b1d9a -[NSPasteboardItem setData:forType:] + 287
        4 libglass.dylib 0x0000000107ef4052 Java_com_sun_glass_ui_mac_MacPasteboard__1putItemsFromArray + 1778
        5 ??? 0x00000001112ee53a 0x0 + 4583253306
        )
        libc++abi: terminating with uncaught exception of type NSException

        Attachments

          Issue Links

            Activity

              People

                kcr Kevin Rushforth
                kcr Kevin Rushforth
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: