mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
restorable: Replace a potentially dangerous pointer usage
Getting a poniter to a loop variable is potentially dangerous.
This commit is contained in:
parent
2106e0fa6a
commit
de14a44c01
@ -84,14 +84,17 @@ func (rtp *rectToPixels) at(i, j int) (byte, byte, byte, byte, bool) {
|
||||
|
||||
var pix []byte
|
||||
|
||||
var r *image.Rectangle
|
||||
var r image.Rectangle
|
||||
var found bool
|
||||
if pt := image.Pt(i, j); pt.In(rtp.lastR) {
|
||||
r = &rtp.lastR
|
||||
r = rtp.lastR
|
||||
found = true
|
||||
pix = rtp.lastPix
|
||||
} else {
|
||||
for rr := range rtp.m {
|
||||
if pt.In(rr) {
|
||||
r = &rr
|
||||
r = rr
|
||||
found = true
|
||||
rtp.lastR = rr
|
||||
pix = rtp.m[rr]
|
||||
rtp.lastPix = pix
|
||||
@ -100,7 +103,7 @@ func (rtp *rectToPixels) at(i, j int) (byte, byte, byte, byte, bool) {
|
||||
}
|
||||
}
|
||||
|
||||
if r == nil {
|
||||
if !found {
|
||||
return 0, 0, 0, 0, false
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user