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

NativeImage bounds checks are incorrect

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 21w18a
    • 1.14.4, 1.15 Pre-release 6, 1.16.1, 1.16.2, 21w06a
    • None
    • Confirmed
    • Crash
    • Very Important

      Bounds checks in NativeImage are incorrect, and it uses UNSAFE to directly access memory, so misusing it can cause the JRE to completely crash instead of throwing an exception. As far as I am aware, this bug is not currently being triggered by any vanilla code that calls NativeImage.

      NativeImage should check that x and y are both >= 0.
      The checks for x <= width should be x < width
      and the checks for y <= height should be y < height.

      Affected methods:

      • NativeImage.getPixelRGBA(int, int)
      • NativeImage.setPixelRGBA(int, int, int)
      • NativeImage.getLuminanceOrAlpha(int, int)

      Note: These methods do not check for negative x or y values either.

            xilefian [Mojang] Felix Jones
            mezz mezz
            Votes:
            6 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: