Skip to content

Commit

Permalink
Prevent panic when editing forked repos by API (go-gitea#14960)
Browse files Browse the repository at this point in the history
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 go-gitea#14956

Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath authored Mar 11, 2021
1 parent c8e5c79 commit 5705f72
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions routers/api/v1/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 5705f72

Please sign in to comment.