diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2023-12-12 14:51:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-12 13:51:33 +0000 |
commit | ff5106d700c51932ae0547212d25b4fbf54ce99a (patch) | |
tree | 34f09ffdcfc181078f9d71e4a7cad81a728ce9ce /services/packages/alpine | |
parent | 0a794b2bcd9f3803e3aa4291387add4e0bb0d124 (diff) | |
download | gitea-ff5106d700c51932ae0547212d25b4fbf54ce99a.tar.gz gitea-ff5106d700c51932ae0547212d25b4fbf54ce99a.zip |
Fix possible nil pointer access (#28428)
There could be a nil pointer exception if the file is not found because
that specific error is suppressed but not handled.
Diffstat (limited to 'services/packages/alpine')
-rw-r--r-- | services/packages/alpine/repository.go | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/services/packages/alpine/repository.go b/services/packages/alpine/repository.go index 46093d5bdd..30b7a06eb3 100644 --- a/services/packages/alpine/repository.go +++ b/services/packages/alpine/repository.go @@ -82,10 +82,7 @@ func BuildAllRepositoryFiles(ctx context.Context, ownerID int64) error { } for _, pf := range pfs { - if err := packages_model.DeleteAllProperties(ctx, packages_model.PropertyTypeFile, pf.ID); err != nil { - return err - } - if err := packages_model.DeleteFileByID(ctx, pf.ID); err != nil { + if err := packages_service.DeletePackageFile(ctx, pf); err != nil { return err } } @@ -157,12 +154,11 @@ func buildPackagesIndex(ctx context.Context, ownerID int64, repoVersion *package pf, err := packages_model.GetFileForVersionByName(ctx, repoVersion.ID, IndexFilename, fmt.Sprintf("%s|%s|%s", branch, repository, architecture)) if err != nil && !errors.Is(err, util.ErrNotExist) { return err + } else if pf == nil { + return nil } - if err := packages_model.DeleteAllProperties(ctx, packages_model.PropertyTypeFile, pf.ID); err != nil { - return err - } - return packages_model.DeleteFileByID(ctx, pf.ID) + return packages_service.DeletePackageFile(ctx, pf) } // Cache data needed for all repository files |