From 624343266b62957c86717bcab706c621d8d2f83a Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Tue, 4 Jul 2023 18:26:24 +0800 Subject: [PATCH] Fix the nil pointer when assigning issues to projects (#25665) Fixes #25649 Caused by #25468 --- routers/web/org/projects.go | 8 +++++--- routers/web/repo/projects.go | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/routers/web/org/projects.go b/routers/web/org/projects.go index e525f2c43f3ac..c568b1c07164c 100644 --- a/routers/web/org/projects.go +++ b/routers/web/org/projects.go @@ -436,9 +436,11 @@ func UpdateIssueProject(ctx *context.Context) { projectID := ctx.FormInt64("id") for _, issue := range issues { - oldProjectID := issue.Project.ID - if oldProjectID == projectID { - continue + if issue.Project != nil { + oldProjectID := issue.Project.ID + if oldProjectID == projectID { + continue + } } if err := issues_model.ChangeProjectAssign(issue, ctx.Doer, projectID); err != nil { diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index 6da9edfd0b802..b1033fe0030e9 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -385,9 +385,11 @@ func UpdateIssueProject(ctx *context.Context) { projectID := ctx.FormInt64("id") for _, issue := range issues { - oldProjectID := issue.Project.ID - if oldProjectID == projectID { - continue + if issue.Project != nil { + oldProjectID := issue.Project.ID + if oldProjectID == projectID { + continue + } } if err := issues_model.ChangeProjectAssign(issue, ctx.Doer, projectID); err != nil {