summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-02-21 18:18:13 +0000
committerGitHub <noreply@github.com>2020-02-21 18:18:13 +0000
commitcadec9bc22624a5a5c3fa006304704f24cda65f3 (patch)
tree95b1d4d12028e5d3ea3c729db9a9eda9ffc15753 /services
parentcfcd8e41467dd17c13c2ef80a6f12ae883f1f9f3 (diff)
downloadgitea-cadec9bc22624a5a5c3fa006304704f24cda65f3.tar.gz
gitea-cadec9bc22624a5a5c3fa006304704f24cda65f3.zip
Prevent panic on merge to PR (#10403)
If you attempt to merge to a branch which on a PR there will be a nil pointer error in the pull request checker. This panic is uncaught and will bring down the gitea server. This PR adds protection to prevent this.
Diffstat (limited to 'services')
-rw-r--r--services/pull/pull.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/services/pull/pull.go b/services/pull/pull.go
index 6e51ad0a24..6af751856d 100644
--- a/services/pull/pull.go
+++ b/services/pull/pull.go
@@ -324,6 +324,10 @@ func PushToBaseRepo(pr *models.PullRequest) (err error) {
}
}()
+ if err := pr.LoadHeadRepo(); err != nil {
+ log.Error("Unable to load head repository for PR[%d] Error: %v", pr.ID, err)
+ return err
+ }
headRepoPath := pr.HeadRepo.RepoPath()
if err := git.Clone(headRepoPath, tmpBasePath, git.CloneRepoOptions{
@@ -340,6 +344,10 @@ func PushToBaseRepo(pr *models.PullRequest) (err error) {
return fmt.Errorf("OpenRepository: %v", err)
}
+ if err := pr.LoadBaseRepo(); err != nil {
+ log.Error("Unable to load base repository for PR[%d] Error: %v", pr.ID, err)
+ return err
+ }
if err := gitRepo.AddRemote("base", pr.BaseRepo.RepoPath(), false); err != nil {
return fmt.Errorf("tmpGitRepo.AddRemote: %v", err)
}