From 39fda4e3d341e59e4955f751cb354a939e57c1b1 Mon Sep 17 00:00:00 2001 From: bnonce <156004085+bnonce@users.noreply.github.com> Date: Sat, 26 Oct 2024 09:17:20 +0300 Subject: [PATCH] fix: copy bytes in mapModel.Scan (#1030) (#1032) --- model_map.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/model_map.go b/model_map.go index 814d636e6..99a5192a3 100644 --- a/model_map.go +++ b/model_map.go @@ -82,7 +82,11 @@ func (m *mapModel) Scan(src interface{}) error { return m.scanRaw(src) case reflect.Slice: if scanType.Elem().Kind() == reflect.Uint8 { - return m.scanRaw(src) + srcB := src.([]byte) + src2 := make([]byte, len(srcB)) + copy(src2, srcB) + + return m.scanRaw(src2) } }