From a7f52684cb7eeb746adf7a6609adbd4d42ae2815 Mon Sep 17 00:00:00 2001 From: zeripath Date: Fri, 6 May 2022 05:54:22 +0200 Subject: [PATCH] Prevent NPE when checking repo units if the user is nil (#19625) CheckRepoUnitUser should tolerate nil users. Fix #19613 Signed-off-by: Andrew Thornton Co-authored-by: wxiaoguang --- models/repo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/repo.go b/models/repo.go index e934b24fb38..fbc766850d9 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)