Skip to content

Commit

Permalink
Fix potential nil enrollment
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepeterson committed Jul 14, 2022
1 parent 560ced9 commit 6772a99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mdm/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func (resolved *ResolvedEnrollment) Validate() error {

// Resolved assembles a ResolvedEnrollment from an Enrollment
func (e *Enrollment) Resolved() (r *ResolvedEnrollment) {
if e == nil {
return
}
if e.UDID != "" {
r = new(ResolvedEnrollment)
r.Type = Device
Expand Down
5 changes: 5 additions & 0 deletions mdm/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import (
"testing"
)

func TestNilResolved(t *testing.T) {
var e *Enrollment
_ = e.Resolved()
}

func TestResolved(t *testing.T) {
for _, test := range []struct {
testName string
Expand Down

0 comments on commit 6772a99

Please sign in to comment.