Fix a possible null pointer dereference
- This commit would fix a potential null pointer dereference.
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: Ic323bde2c4bd35c35132e4310466cd6ae7ec7aeb
Signed-off-by: George Liu <liuxiwei@inspur.com>
diff --git a/softoff/softoff.cpp b/softoff/softoff.cpp
index d215c1d..a704885 100644
--- a/softoff/softoff.cpp
+++ b/softoff/softoff.cpp
@@ -258,6 +258,12 @@
pdr = reinterpret_cast<pldm_state_sensor_pdr*>(rep.data());
}
+ if (!pdr)
+ {
+ std::cerr << "Failed to get state sensor PDR.\n";
+ return PLDM_ERROR;
+ }
+
sensorID = pdr->sensor_id;
auto compositeSensorCount = pdr->composite_sensor_count;