Skip to content

Commit

Permalink
internal/atlas: bug fix: possible overflowing on 32bit machines
Browse files Browse the repository at this point in the history
Closes #2728
  • Loading branch information
hajimehoshi committed Aug 18, 2023
1 parent 14c03e9 commit a5af6dc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/atlas/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package atlas
import (
"fmt"
"image"
"math"
"runtime"
"sync"

Expand Down Expand Up @@ -113,8 +114,10 @@ const baseCountToPutOnSourceBackend = 10

func putImagesOnSourceBackend(graphicsDriver graphicsdriver.Graphics) error {
for i := range imagesToPutOnSourceBackend {
i.usedAsSourceCount++
if i.usedAsSourceCount >= baseCountToPutOnSourceBackend*(1<<uint(min(i.destinationCount, 31))) {
if i.usedAsSourceCount < math.MaxInt {
i.usedAsSourceCount++
}
if int64(i.usedAsSourceCount) >= int64(baseCountToPutOnSourceBackend*(1<<uint(min(i.destinationCount, 31)))) {
if err := i.putOnSourceBackend(graphicsDriver); err != nil {
return err
}
Expand Down

0 comments on commit a5af6dc

Please sign in to comment.