Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-167344

com.mojang.blaze3d.platform.ClipboardManager leaks direct buffers

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.15 Pre-release 6
    • Fix Version/s: 1.15.2 Pre-Release 1
    • Labels:
      None
    • Confirmation Status:
      Plausible
    • Category:
      Crash
    • Mojang Priority:
      Normal

      Description

      The bug

      In com.mojang.blaze3d.platform.ClipboardManager (Mojang name):
      The class has one buffer of the size 1024 which it reuses if the UTF-8 encoded string to copy is not larger. However, if it is larger it allocates a new direct buffer in setClipboard(...) which it never frees.

      This should be solved by not using ByteBuffer.allocateDirect (which is also discouraged by LWJGL), but instead using MemoryStack's malloc​ / calloc, or MemoryUtil's methods if the data becomes too large for the stack (?).
      And yes, it should be safe to free the memory of the temporary buffer since glfwSetClipboardString says:

      The specified string is copied before this function returns.

        Attachments

          Activity

            People

            • Assignee:
              boq [Mojang] Bartosz Bok
              Reporter:
              marcono1234 [Mod] Marcono1234
            • Votes:
              4 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                CHK:

                Potential Duplicates