Skip to content

Commit 18dd49a

Browse files
zeripathwxiaoguang
andauthored
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 <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent 46637b1 commit 18dd49a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

models/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func CheckRepoUnitUser(repo *repo_model.Repository, user *user_model.User, unitT
132132
}
133133

134134
func checkRepoUnitUser(ctx context.Context, repo *repo_model.Repository, user *user_model.User, unitType unit.Type) bool {
135-
if user.IsAdmin {
135+
if user != nil && user.IsAdmin {
136136
return true
137137
}
138138
perm, err := getUserRepoPermission(ctx, repo, user)

0 commit comments

Comments
 (0)