Mojira Archive
MC-162953

NativeImage bounds checks are incorrect

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.

Fixed

mezz

[Mojang] Felix Jones

2019-10-08, 09:26 AM

2021-05-05, 12:18 PM

2021-05-05, 12:18 PM

6

5

Confirmed

Very Important

Crash

1.14.4 - 21w06a1.14.4, 1.15 Pre-release 6, 1.16.1, 1.16.2, 21w06a

21w18a