1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-22 15:03:57 +00:00

Fix: copy the data in buffer instead of using original data. (#1425)

This commit is contained in:
Spedoske 2021-07-11 18:35:02 +08:00 committed by GitHub
parent 08b2b71197
commit cd802dfead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -160,8 +160,12 @@ func (s *Session) Save() error {
return err
}
// pass raw bytes with session id to provider
if err := s.config.Storage.Set(s.id, s.byteBuffer.Bytes(), s.exp); err != nil {
// copy the data in buffer
encodedBytes := make([]byte, s.byteBuffer.Len())
copy(encodedBytes, s.byteBuffer.Bytes())
// pass copied bytes with session id to provider
if err := s.config.Storage.Set(s.id, encodedBytes, s.exp); err != nil {
return err
}