diff options
author | zeripath <art27@cantab.net> | 2021-09-30 20:31:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 21:31:02 +0200 |
commit | 206ea10b45e8659eb3227239d3012b20dbb24231 (patch) | |
tree | 7629d37ca57165410a76f9adce6ddb60bd3e357b /integrations/compare_test.go | |
parent | 3bbdce26012d02d3b5082f8774ce432ad9c2990b (diff) | |
download | gitea-206ea10b45e8659eb3227239d3012b20dbb24231.tar.gz gitea-206ea10b45e8659eb3227239d3012b20dbb24231.zip |
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>
Diffstat (limited to 'integrations/compare_test.go')
-rw-r--r-- | integrations/compare_test.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/integrations/compare_test.go b/integrations/compare_test.go index 08468cbfd6..e8efe7cd09 100644 --- a/integrations/compare_test.go +++ b/integrations/compare_test.go @@ -6,6 +6,7 @@ package integrations import ( "net/http" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -21,4 +22,8 @@ func TestCompareTag(t *testing.T) { selection := htmlDoc.doc.Find(".choose.branch .filter.dropdown") // A dropdown for both base and head. assert.Lenf(t, selection.Nodes, 2, "The template has changed") + + req = NewRequest(t, "GET", "/user2/repo1/compare/invalid") + resp = session.MakeRequest(t, req, http.StatusNotFound) + assert.False(t, strings.Contains(resp.Body.String(), "/assets/img/500.png"), "expect 404 page not 500") } |