aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-05-06 12:01:08 +0200
committerGitHub <noreply@github.com>2022-05-06 18:01:08 +0800
commit18dd49a4abadb62c1cc686cbfb8aacfe95b47001 (patch)
tree96f41480f88c0047ca3eb67aa37b05001e758d14
parent46637b1164a2da6fed013d1acc151c79c192da83 (diff)
downloadgitea-18dd49a4abadb62c1cc686cbfb8aacfe95b47001.tar.gz
gitea-18dd49a4abadb62c1cc686cbfb8aacfe95b47001.zip
Prevent NPE when checking repo units if the user is nil (#19625) (#19630)
Backport #19625 CheckRepoUnitUser should tolerate nil users. Fix #19613 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
-rw-r--r--models/repo.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go
index e82fd5dedf..29bb196e8e 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -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)