geforkt von Mirrors/Paper
Added negative id check to Material.getMaterial(int). Fixes BUKKIT-3414
Negative id values would try to access the array out of bounds and throw an java.lang.ArrayIndexOutOfBoundsException. By: MikeMatrix <m.braun92@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
de7c26870b
Commit
08fa8ed053
@ -528,7 +528,7 @@ public enum Material {
|
|||||||
* @return Material if found, or null
|
* @return Material if found, or null
|
||||||
*/
|
*/
|
||||||
public static Material getMaterial(final int id) {
|
public static Material getMaterial(final int id) {
|
||||||
if (byId.length > id) {
|
if (byId.length > id && id >= 0) {
|
||||||
return byId[id];
|
return byId[id];
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -33,6 +33,7 @@ public class MaterialTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getByOutOfRangeId() {
|
public void getByOutOfRangeId() {
|
||||||
assertThat(Material.getMaterial(Integer.MAX_VALUE), is(nullValue()));
|
assertThat(Material.getMaterial(Integer.MAX_VALUE), is(nullValue()));
|
||||||
|
assertThat(Material.getMaterial(Integer.MIN_VALUE), is(nullValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren