From 4fb750de439f306907671c8f70de026b36d3a359 Mon Sep 17 00:00:00 2001 From: rnauber <7414650+rnauber@users.noreply.github.com> Date: Mon, 15 Jun 2020 05:37:15 +0200 Subject: [PATCH] ADE7953: Fix dereferencing of a null pointer (#1086) * ADE7953: Fix dereferencing of a null pointer The ade7953 driver dereferences a null pointer, when not all of its sensors are used. This gives an exception like: Fatal exception:29 flag:2 (EXCEPTION) epc1:0x4020c241 epc2:0x00000000 epc3:0x00000000 excvaddr:0x00000018 depc:0x00000000 * Fix formatting Co-authored-by: olg --- esphome/components/ade7953/ade7953.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/ade7953/ade7953.cpp b/esphome/components/ade7953/ade7953.cpp index 9316d9cad0..c4752abf39 100644 --- a/esphome/components/ade7953/ade7953.cpp +++ b/esphome/components/ade7953/ade7953.cpp @@ -18,7 +18,7 @@ void ADE7953::dump_config() { } #define ADE_PUBLISH_(name, factor) \ - if (name) { \ + if (name && this->name##_sensor_) { \ float value = *name / factor; \ this->name##_sensor_->publish_state(value); \ }