From 229a2d2b343d71121f8d080f1a1df100fc9f8e5b Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 10 May 2023 16:16:59 +0200 Subject: [PATCH] Dereference pointers when publishing (#7905) --- util/tee.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/util/tee.go b/util/tee.go index eb8670f45..69318c71a 100644 --- a/util/tee.go +++ b/util/tee.go @@ -1,5 +1,7 @@ package util +import "reflect" + // TeeAttacher allows to attach a listener to a tee type TeeAttacher interface { Attach() <-chan Param @@ -28,6 +30,13 @@ func (t *Tee) add(out chan<- Param) { func (t *Tee) Run(in <-chan Param) { for msg := range in { for _, recv := range t.recv { + // dereference pointers (https://github.com/evcc-io/evcc/issues/7895) + if val := reflect.ValueOf(msg.Val); val.Kind() == reflect.Ptr { + if ptr := reflect.Indirect(val); ptr.IsValid() { + msg.Val = ptr.Addr().Elem().Interface() + } + } + recv <- msg } }