aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-07-28 21:02:53 +0200
committerGitHub <noreply@github.com>2022-07-28 20:02:53 +0100
commit9aa13c585e0128127b38e392a34bb32678b491c9 (patch)
tree1b13684d1689b518c58dbe2b967a588e945be90a
parenteeaa9250e0fa5df49378be887917c28ff819ed2c (diff)
downloadgitea-release/v1.16.tar.gz
gitea-release/v1.16.zip
Fix possible panic when repository is empty (#20509) (#20527)release/v1.16
-rw-r--r--routers/web/repo/view.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index e98d94f7ca..adc0802404 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -856,10 +856,14 @@ func renderCode(ctx *context.Context) {
ctx.Data["PageIsViewCode"] = true
if ctx.Repo.Repository.IsEmpty {
- reallyEmpty, err := ctx.Repo.GitRepo.IsEmpty()
- if err != nil {
- ctx.ServerError("GitRepo.IsEmpty", err)
- return
+ reallyEmpty := true
+ var err error
+ if ctx.Repo.GitRepo != nil {
+ reallyEmpty, err = ctx.Repo.GitRepo.IsEmpty()
+ if err != nil {
+ ctx.ServerError("GitRepo.IsEmpty", err)
+ return
+ }
}
if reallyEmpty {
ctx.HTML(http.StatusOK, tplRepoEMPTY)