Skip to content

Commit

Permalink
GODRIVER-1793 Avoid crash when opts is [nil] in InsertOne
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangz222 authored and kevinAlbs committed Nov 30, 2020
1 parent 3ce1141 commit 3069e04
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mongo/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (coll *Collection) InsertOne(ctx context.Context, document interface{},
imOpts := make([]*options.InsertManyOptions, len(opts))
for i, opt := range opts {
imo := options.InsertMany()
if opt.BypassDocumentValidation != nil && *opt.BypassDocumentValidation {
if opt != nil && opt.BypassDocumentValidation != nil && *opt.BypassDocumentValidation {
imo = imo.SetBypassDocumentValidation(*opt.BypassDocumentValidation)
}
imOpts[i] = imo
Expand Down

0 comments on commit 3069e04

Please sign in to comment.