Fix a segmentation fault error in the updateProperty method
Program received signal SIGSEGV, Segmentation fault.
Sensor::updateProperty (this=0x4f4ae0, interface=..., oldValue=@0x4f4b80: nan(0x8000000000000),
newValue=@0x7efff778: nan(0x8000000000000), dbusPropertyName=0x47d567 "Value")
at /usr/src/debug/dbus-sensors/0.1+gitAUTOINC+623723b9e8-r0/git/include/sensor.hpp:307
It was caused by a missing null pointer checking on a dBus interface
so this commit adds the null pointer checking. This case can be
happened on Tjmax and Tthrottle in CPU sensors that intentionally
removed sensorInterface to make itself as a hidden sensor.
Change-Id: Idb5ed40777bf8a15258f864379d3decbcea779c3
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
diff --git a/include/sensor.hpp b/include/sensor.hpp
index 973362b..a8321fd 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -304,7 +304,8 @@
if (requiresUpdate(oldValue, newValue))
{
oldValue = newValue;
- if (!(interface->set_property(dbusPropertyName, newValue)))
+ if (interface &&
+ !(interface->set_property(dbusPropertyName, newValue)))
{
std::cerr << "error setting property " << dbusPropertyName
<< " to " << newValue << "\n";