From 5f8a0e34bbb46071f0c249c48fa8525788747cda Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 16 Dec 2018 14:22:47 +0900 Subject: [PATCH] graphics: isPowerOf2(0 or negative) should return false --- internal/graphics/vertices.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/graphics/vertices.go b/internal/graphics/vertices.go index a6276520b..5ef8af029 100644 --- a/internal/graphics/vertices.go +++ b/internal/graphics/vertices.go @@ -50,6 +50,9 @@ func (v *verticesBackend) slice(n int) []float32 { } func isPowerOf2(x int) bool { + if x <= 0 { + return false + } return (x & (x - 1)) == 0 }