diff options
author | zeripath <art27@cantab.net> | 2021-03-11 18:09:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-11 19:09:52 +0100 |
commit | 5705f72fd6a1c0ebe3f3127faa7ebea5af7100d0 (patch) | |
tree | 4f3853ce9f5c1311077c965d7071a9b1e78e0999 /routers | |
parent | c8e5c79cfda7e4c36b1a98c1abd3cdb50bde9d77 (diff) | |
download | gitea-5705f72fd6a1c0ebe3f3127faa7ebea5af7100d0.tar.gz gitea-5705f72fd6a1c0ebe3f3127faa7ebea5af7100d0.zip |
Prevent panic when editing forked repos by API (#14960)
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>
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 b12797f83b..b7ed2951ad 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -556,6 +556,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 } |