sensord: fix memory leak when legacy cb is used 04/64504/1
authorkibak.yoon <kibak.yoon@samsung.com>
Thu, 31 Mar 2016 01:24:52 +0000 (10:24 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Fri, 1 Apr 2016 10:40:21 +0000 (19:40 +0900)
* when legacy cb is used, allocation of event is useless

Change-Id: I1698884940a6744f78963a28746e5b9e4313ec00
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/client/sensor_event_listener.cpp

index 99cf76e..d344554 100644 (file)
@@ -110,14 +110,14 @@ client_callback_info* sensor_event_listener::handle_calibration_cb(sensor_handle
                if (!event_info)
                        return NULL;
 
-               sensor_data_t *cal_data = (sensor_data_t *)malloc(sizeof(sensor_data_t));
-               retvm_if(!cal_data, NULL, "Failed to allocate memory");
-
                if (event_info->m_cb_type == SENSOR_LEGACY_CB) {
                        cal_event_data.event_data = (void *)&(accuracy);
                        cal_event_data.event_data_size = sizeof(accuracy);
                        cal_sensor_data = &cal_event_data;
                } else {
+                       sensor_data_t *cal_data = (sensor_data_t *)malloc(sizeof(sensor_data_t));
+                       retvm_if(!cal_data, NULL, "Failed to allocate memory");
+
                        cal_data->accuracy = accuracy;
                        cal_data->timestamp = time;
                        cal_data->values[0] = accuracy;