Skip to content

Commit

Permalink
Manually update files.
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Jun 27, 2024
1 parent 0a089c8 commit 1c6eb28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bson/default_value_decoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func intDecodeType(dc DecodeContext, vr ValueReader, t reflect.Type) (reflect.Va
case reflect.Int64:
return reflect.ValueOf(i64), nil
case reflect.Int:
if int64(int(i64)) != i64 { // Can we fit this inside of an int
if i64 > math.MaxInt { // Can we fit this inside of an int
return emptyValue, fmt.Errorf("%d overflows int", i64)
}

Expand Down
4 changes: 4 additions & 0 deletions mongo/writeconcern/writeconcern.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package writeconcern
import (
"errors"
"fmt"
"math"
"time"

"go.mongodb.org/mongo-driver/bson"
Expand Down Expand Up @@ -169,6 +170,9 @@ func (wc *WriteConcern) MarshalBSONValue() (bson.Type, []byte, error) {
return 0, nil, ErrInconsistent
}

if w > math.MaxInt32 {
return 0, nil, fmt.Errorf("%d overflows int32", w)
}
elems = bsoncore.AppendInt32Element(elems, "w", int32(w))
case string:
elems = bsoncore.AppendStringElement(elems, "w", w)
Expand Down

0 comments on commit 1c6eb28

Please sign in to comment.