[Non-ACR][TFIVE-357] 70/175170/2 accepted/tizen/unified/20180412.073802 submit/tizen/20180410.084125
authorAbhishek Vijay <abhishek.v@samsung.com>
Mon, 9 Apr 2018 06:46:36 +0000 (12:16 +0530)
committerAbhishek Vijay <abhishek.v@samsung.com>
Mon, 9 Apr 2018 06:49:06 +0000 (06:49 +0000)
Change-Id: Ice9b6976fca4013140b1fc90ffb88c4120e600c0
Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
src/server/sensor_event_handler.cpp

index 4fac18d..73b5a05 100644 (file)
@@ -35,7 +35,7 @@ sensor_event_handler::sensor_event_handler(physical_sensor_handler *sensor)
 bool sensor_event_handler::handle(int fd, ipc::event_condition condition)
 {
        sensor_info info;
-       sensor_data_t *data;
+       sensor_data_t *data = NULL;
        int length = 0;
        int remains = 1;
 
@@ -56,14 +56,18 @@ bool sensor_event_handler::handle(int fd, ipc::event_condition condition)
 
                if (m_sensor->on_event(data, length, remains) < 0) {
                        free(data);
+                       data = NULL;
                        continue;
                }
 
                info = m_sensor->get_sensor_info();
 
                //_I("[Data] allocate %p", data);
-               if (m_sensor->notify(info.get_uri().c_str(), data, length) < 0) {
-                       free(data);
+               if (data) {
+                       if (m_sensor->notify(info.get_uri().c_str(), data, length) < 0) {
+                               free(data);
+                               data = NULL;
+                       }
                }
                info.clear();
        }