From b2a80f214940b10e34bc05aeac62fd1d9f7748e2 Mon Sep 17 00:00:00 2001 From: John Regan Date: Mon, 24 Jul 2023 18:12:04 -0400 Subject: [PATCH] s3Storage: fix slice bounds out of range error (#3208) --- core/storageproviders/s3Storage.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/storageproviders/s3Storage.go b/core/storageproviders/s3Storage.go index 6e3177053..cef381693 100644 --- a/core/storageproviders/s3Storage.go +++ b/core/storageproviders/s3Storage.go @@ -200,7 +200,9 @@ func (s *S3Storage) Cleanup() error { return err } - s.deleteObjects(keys) + if len(keys) > 0 { + s.deleteObjects(keys) + } return nil } @@ -241,6 +243,10 @@ func (s *S3Storage) getDeletableVideoSegmentsWithOffset(offset int) ([]s3object, return nil, err } + if offset > len(objectsToDelete)-1 { + offset = len(objectsToDelete) - 1 + } + objectsToDelete = objectsToDelete[offset : len(objectsToDelete)-1] return objectsToDelete, nil