Skip to content

Commit

Permalink
fix profileData initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
mycrEEpy committed Aug 18, 2023
1 parent 5336909 commit 7c4aead
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/pgopher/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (p profileCollector) Run() {
case "kubernetes":
name := fmt.Sprintf("pgopher-profile-%s", p.target.Name)

profileData := make([]byte, 0, buf.Len())
profileData := make([]byte, base64.StdEncoding.EncodedLen(buf.Len()))

base64.StdEncoding.Encode(profileData, buf.Bytes())

Expand Down
2 changes: 1 addition & 1 deletion internal/pgopher/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *Server) handleProfile(ctx echo.Context) error {
defer file.Close()
defer os.Remove(file.Name())

profileData := make([]byte, 0, len(resp.Data["profile"]))
profileData := make([]byte, base64.StdEncoding.DecodedLen(len(resp.Data["profile"])))

_, err = base64.StdEncoding.Decode(profileData, resp.Data["profile"])
if err != nil {
Expand Down

0 comments on commit 7c4aead

Please sign in to comment.