mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +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 {
|
func pow2(x uintptr) uintptr {
|
||||||
|
if x > (math.MaxUint+1)/2 {
|
||||||
|
return math.MaxUint
|
||||||
|
}
|
||||||
|
|
||||||
var p2 uintptr = 1
|
var p2 uintptr = 1
|
||||||
for p2 < x {
|
for p2 < x {
|
||||||
p2 *= 2
|
p2 *= 2
|
||||||
|
@ -16,6 +16,7 @@ package opengl
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"runtime"
|
"runtime"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@ -157,6 +158,10 @@ func (s *openGLState) reset(context *context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func pow2(x int) int {
|
func pow2(x int) int {
|
||||||
|
if x > (math.MaxInt+1)/2 {
|
||||||
|
return math.MaxInt
|
||||||
|
}
|
||||||
|
|
||||||
p2 := 1
|
p2 := 1
|
||||||
for p2 < x {
|
for p2 < x {
|
||||||
p2 *= 2
|
p2 *= 2
|
||||||
|
Loading…
Reference in New Issue
Block a user