Pi4J / pi4j-v1

DEPRECATED Java I/O library for Raspberry Pi (GPIO, I2C, SPI, UART)
http://www.pi4j.com
Apache License 2.0
1.31k stars 447 forks source link

ArrayIndex Out of Bounds in case the adress is 100 #438

Closed JozefDropco closed 5 years ago

JozefDropco commented 5 years ago

Hi, this is a great library to use with Raspberry. I really appreciate your effort.

There is a small bug in code which causes array out of bounds. While checking the Pin cache size you are comparing adress with array length. Instead it should be length-1 as the index cannot be 100 this caused an issue in my code. java.lang.ArrayIndexOutOfBoundsException: 100 at com.pi4j.io.gpio.GpioProviderBase.getPinCache(GpioProviderBase.java:88) at com.pi4j.io.gpio.GpioProviderBase.export(GpioProviderBase.java:119) at com.pi4j.io.gpio.GpioProviderBase.export(GpioProviderBase.java:100) at com.pi4j.io.gpio.impl.GpioPinImpl.export(GpioPinImpl.java:158)

I would like also to ask is there any plan for release 1.2?

savageautomate commented 5 years ago

FIX #438; array auto-expansion should be triggered if requested pin address is GREATER THAN or EQUAL to the current pin cache length.

savageautomate commented 5 years ago

Yes, working on a 1.2 release now.