From 51e0b5e306b367c19fc4ef10f9cc24dd87a1ff2c Mon Sep 17 00:00:00 2001
From: Jeremie Deray <jeremie.deray@pal-robotics.com>
Date: Tue, 18 Jul 2017 14:47:30 +0200
Subject: [PATCH] check nullptr in SensorBase/ProcessorMotion Process()

---
 src/processor_motion.cpp | 6 +++++-
 src/sensor_base.h        | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/processor_motion.cpp b/src/processor_motion.cpp
index e17c407c9..0cbdd2863 100644
--- a/src/processor_motion.cpp
+++ b/src/processor_motion.cpp
@@ -35,7 +35,11 @@ ProcessorMotion::~ProcessorMotion()
 
 void ProcessorMotion::process(CaptureBasePtr _incoming_ptr)
 {
-
+  if (_incoming_ptr == nullptr)
+  {
+    WOLF_ERROR("Process got a nullptr !");
+    return;
+  }
 
     if (status_ == IDLE)
     {
diff --git a/src/sensor_base.h b/src/sensor_base.h
index 9b8bd4e6f..b68585d6f 100644
--- a/src/sensor_base.h
+++ b/src/sensor_base.h
@@ -256,6 +256,8 @@ inline void SensorBase::setHardwarePtr(const HardwareBasePtr _hw_ptr)
 
 inline bool SensorBase::process(const CaptureBasePtr capture_ptr)
 {
+  if (capture_ptr == nullptr) return false;
+
   capture_ptr->setSensorPtr(shared_from_this());
 
   for (const auto processor : processor_list_)
-- 
GitLab