diff options
author | 6543 <6543@obermui.de> | 2021-03-12 01:54:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-12 08:54:18 +0800 |
commit | 33c2c49627455bd19d411ecd858c2ca2eceab731 (patch) | |
tree | c5a70a7f97b4556445500f23c9ec0426a7ff74fc /routers | |
parent | 05ac72cf33e2e3baac4e0dc0fd83ca87292a4a91 (diff) | |
download | gitea-33c2c49627455bd19d411ecd858c2ca2eceab731.tar.gz gitea-33c2c49627455bd19d411ecd858c2ca2eceab731.zip |
Prevent panic when editing forked repos by API (#14960) (#14963)
When editing forked repos using the API the BaseRepository needs to loaded
in order to check its visibility otherwise there will be NPE panic.
Fix #14956
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/repo.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 116e413125..53ec0618ce 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -539,6 +539,10 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err if opts.Private != nil { // Visibility of forked repository is forced sync with base repository. if repo.IsFork { + if err := repo.GetBaseRepo(); err != nil { + ctx.Error(http.StatusInternalServerError, "Unable to load base repository", err) + return err + } *opts.Private = repo.BaseRepo.IsPrivate } |