mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Prevent NPE on invalid diff (#17197)
* Prevent NPE on invalid diff If ParseCompareInfo returns a nil compare info the defer function needs to ensure that it does not attempt to close the HeadGitRepo. Fix #17193 Signed-off-by: Andrew Thornton <art27@cantab.net> * add TEST Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
@@ -1043,7 +1043,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
|
||||
|
||||
ci := ParseCompareInfo(ctx)
|
||||
defer func() {
|
||||
if ci.HeadGitRepo != nil {
|
||||
if ci != nil && ci.HeadGitRepo != nil {
|
||||
ci.HeadGitRepo.Close()
|
||||
}
|
||||
}()
|
||||
|
Reference in New Issue
Block a user