From c6c3754f021d208d795bdf8b1ca04d027cdd827b Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:19:13 +1000 Subject: [PATCH] Fix panic when deleting image with no files (#5328) --- pkg/sqlite/image.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/sqlite/image.go b/pkg/sqlite/image.go index db40d4f474b..4f61c17773c 100644 --- a/pkg/sqlite/image.go +++ b/pkg/sqlite/image.go @@ -528,7 +528,10 @@ func (qb *ImageStore) GetFiles(ctx context.Context, id int) ([]models.File, erro return nil, err } - return files, nil + ret := make([]models.File, len(files)) + copy(ret, files) + + return ret, nil } func (qb *ImageStore) GetManyFileIDs(ctx context.Context, ids []int) ([][]models.FileID, error) {