Skip to content

Commit

Permalink
Ensure issue.Poster is loaded in mailIssueCommentToParticipants (#5891)
Browse files Browse the repository at this point in the history
Previous code could potentially dereference nil - this PR ensures
that the poster is loaded before dereferencing it.

Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath authored and techknowlogick committed Jan 29, 2019
1 parent 8917d66 commit 036964b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models/issue_mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func mailIssueCommentToParticipants(e Engine, issue *Issue, doer *User, content

// In case the issue poster is not watching the repository and is active,
// even if we have duplicated in watchers, can be safely filtered out.
poster, err := getUserByID(e, issue.PosterID)
err = issue.loadPoster(e)
if err != nil {
return fmt.Errorf("GetUserByID [%d]: %v", issue.PosterID, err)
}
if issue.PosterID != doer.ID && poster.IsActive && !poster.ProhibitLogin {
if issue.PosterID != doer.ID && issue.Poster.IsActive && !issue.Poster.ProhibitLogin {
participants = append(participants, issue.Poster)
}

Expand Down

0 comments on commit 036964b

Please sign in to comment.