Skip to content

Commit

Permalink
Prevent NPE when checking repo units if the user is nil (#19625) (#19630
Browse files Browse the repository at this point in the history
)

Backport #19625

CheckRepoUnitUser should tolerate nil users.

Fix #19613

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
  • Loading branch information
zeripath and wxiaoguang authored May 6, 2022
1 parent 46637b1 commit 18dd49a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func CheckRepoUnitUser(repo *repo_model.Repository, user *user_model.User, unitT
}

func checkRepoUnitUser(ctx context.Context, repo *repo_model.Repository, user *user_model.User, unitType unit.Type) bool {
if user.IsAdmin {
if user != nil && user.IsAdmin {
return true
}
perm, err := getUserRepoPermission(ctx, repo, user)
Expand Down

0 comments on commit 18dd49a

Please sign in to comment.