[Tizen 5.0] Sensord: Fix memory leak 78/192378/1
authorIngi Kim <ingi2.kim@samsung.com>
Thu, 25 Oct 2018 09:52:25 +0000 (18:52 +0900)
committerIngi Kim <ingi2.kim@samsung.com>
Mon, 5 Nov 2018 06:00:48 +0000 (15:00 +0900)
Memory leak is detected by DML.

physical_sensor_handler:get_data() pushed data to ids which is vector type
but it isn't cleared till end of execution.

Change-Id: I1b20b3c4feefc8ba7ade7a9ae0c80ae40a8a9ec7
Signed-off-by: Ingi Kim <ingi2.kim@samsung.com>
src/server/sensor_event_handler.cpp

index 73b5a05..a3422a7 100644 (file)
@@ -45,7 +45,10 @@ bool sensor_event_handler::handle(int fd, ipc::event_condition condition)
        auto result = std::find(std::begin(ids), std::end(ids), m_sensor->get_hal_id());
 
        if (result == std::end(ids))
+       {
+               ids.clear();
                return true;
+       }
 
        while (remains > 0) {
                remains = m_sensor->get_data(&data, &length);
@@ -72,5 +75,7 @@ bool sensor_event_handler::handle(int fd, ipc::event_condition condition)
                info.clear();
        }
 
+       ids.clear();
+
        return true;
 }