Merge pull request #92 from tinygo-org/st7789-buffer-overflow

st7789: fix index out of bounds error
This commit is contained in:
Daniel Esteban
2019-10-28 12:30:44 +01:00
committed by GitHub
+7 -6
View File
@@ -194,12 +194,13 @@ func (d *Device) FillRectangleWithBuffer(x, y, width, height int16, buffer []col
offset := int32(0)
for k > 0 {
for i := int32(0); i < d.batchLength; i++ {
c565 := RGBATo565(buffer[offset+i])
c1 := uint8(c565 >> 8)
c2 := uint8(c565)
data[i*2] = c1
data[i*2+1] = c2
if offset+i < int32(len(buffer)) {
c565 := RGBATo565(buffer[offset+i])
c1 := uint8(c565 >> 8)
c2 := uint8(c565)
data[i*2] = c1
data[i*2+1] = c2
}
}
if k >= d.batchLength {
d.Tx(data, false)