Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed integer overflow issue causing windows cross compile to fail #24

Merged
merged 1 commit into from
Jul 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions decoder.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gltf

import (
"math"
"bufio"
"bytes"
"encoding/binary"
Expand All @@ -15,8 +16,8 @@ import (
)

const (
defaultMaxExternalBufferCount = 10
defaultMaxMemoryAllocation = 4 * 1024 * 1024 * 1024 // 4GB
defaultMaxExternalBufferCount = 10
defaultMaxMemoryAllocation = math.MaxUint32 // 4GB
)

// ReadHandler is the interface that wraps the ReadFullResource method.
Expand Down Expand Up @@ -47,7 +48,7 @@ func Open(name string) (*Document, error) {
type Decoder struct {
ReadHandler ReadHandler
MaxExternalBufferCount int
MaxMemoryAllocation int
MaxMemoryAllocation uint64
r *bufio.Reader
}

Expand Down Expand Up @@ -93,9 +94,9 @@ func (d *Decoder) Decode(doc *Document) error {

func (d *Decoder) validateDocumentQuotas(doc *Document, isBinary bool) error {
var externalCount int
var allocs int
var allocs uint64
for _, b := range doc.Buffers {
allocs += int(b.ByteLength)
allocs += uint64(b.ByteLength)
if !b.IsEmbeddedResource() {
externalCount++
}
Expand Down