diff options
author | zeripath <art27@cantab.net> | 2022-05-06 05:54:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-06 11:54:22 +0800 |
commit | a7f52684cb7eeb746adf7a6609adbd4d42ae2815 (patch) | |
tree | 566abaa993323b93e08f717f53971102f7b22593 /models/repo.go | |
parent | 4691e598280bbfcb1c8e494e2e74b6ece796c36c (diff) | |
download | gitea-a7f52684cb7eeb746adf7a6609adbd4d42ae2815.tar.gz gitea-a7f52684cb7eeb746adf7a6609adbd4d42ae2815.zip |
Prevent NPE when checking repo units if the user is nil (#19625)
CheckRepoUnitUser should tolerate nil users.
Fix #19613
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go index e934b24fb3..fbc766850d 100644 --- a/models/repo.go +++ b/models/repo.go @@ -54,7 +54,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) |