mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/graphicsdriver/opengl: bug fix: potential infinite loop
This commit is contained in:
parent
c27d191dd5
commit
a19ff07130
@ -133,6 +133,10 @@ func (g *Graphics) SetUIView(uiview uintptr) {
|
||||
}
|
||||
|
||||
func pow2(x uintptr) uintptr {
|
||||
if x > (math.MaxUint+1)/2 {
|
||||
return math.MaxUint
|
||||
}
|
||||
|
||||
var p2 uintptr = 1
|
||||
for p2 < x {
|
||||
p2 *= 2
|
||||
|
@ -16,6 +16,7 @@ package opengl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"runtime"
|
||||
"unsafe"
|
||||
|
||||
@ -157,6 +158,10 @@ func (s *openGLState) reset(context *context) error {
|
||||
}
|
||||
|
||||
func pow2(x int) int {
|
||||
if x > (math.MaxInt+1)/2 {
|
||||
return math.MaxInt
|
||||
}
|
||||
|
||||
p2 := 1
|
||||
for p2 < x {
|
||||
p2 *= 2
|
||||
|
Loading…
Reference in New Issue
Block a user