Skip to content

Commit

Permalink
fix: rpm sign resource leak (#4878)
Browse files Browse the repository at this point in the history
Fixed the resource leak  in #4780.

Related:  [go-gitea/gitea#31794](go-gitea/gitea#31794)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4878
Reviewed-by: Earl Warren <[email protected]>
Co-authored-by: Exploding Dragon <[email protected]>
Co-committed-by: Exploding Dragon <[email protected]>
  • Loading branch information
ExplodingDragon authored and Earl Warren committed Aug 8, 2024
1 parent abc3364 commit 1bc9864
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion routers/api/packages/rpm/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,14 @@ func UploadPackageFile(ctx *context.Context) {
apiError(ctx, http.StatusInternalServerError, err)
return
}
buf, err = rpm_service.NewSignedRPMBuffer(buf, pri)
signedBuf, err := rpm_service.NewSignedRPMBuffer(buf, pri)
if err != nil {
// Not in rpm format, parsing failed.
apiError(ctx, http.StatusBadRequest, err)
return
}
defer signedBuf.Close()
buf = signedBuf
}

pck, err := rpm_module.ParsePackage(buf)
Expand Down

0 comments on commit 1bc9864

Please sign in to comment.