forked from enlightenment/efl
eeze/sensor: Fix leaks when getting allocated data from obj_get
SVN revision: 80882
This commit is contained in:
parent
d0b3c4a96d
commit
d13ca5705f
|
@ -154,16 +154,21 @@ eeze_sensor_new(Eeze_Sensor_Type type)
|
||||||
Eeze_Sensor_Obj *sens;
|
Eeze_Sensor_Obj *sens;
|
||||||
Eeze_Sensor_Module *module = NULL;
|
Eeze_Sensor_Module *module = NULL;
|
||||||
|
|
||||||
sens = calloc(1, sizeof(Eeze_Sensor_Obj));
|
|
||||||
if (!sens) return NULL;
|
|
||||||
|
|
||||||
sens = eeze_sensor_obj_get(type);
|
sens = eeze_sensor_obj_get(type);
|
||||||
if (!sens) return NULL;
|
if (!sens) return NULL;
|
||||||
|
|
||||||
module = _highest_priority_module_get();
|
module = _highest_priority_module_get();
|
||||||
if (!module) return EINA_FALSE;
|
if (!module)
|
||||||
|
{
|
||||||
|
free(sens);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!module->read) return NULL;
|
if (!module->read)
|
||||||
|
{
|
||||||
|
free(sens);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* The read is asynchronous here as we want to make sure that the sensor
|
/* The read is asynchronous here as we want to make sure that the sensor
|
||||||
* object has valid data when created. As we give back cached values we
|
* object has valid data when created. As we give back cached values we
|
||||||
|
@ -175,6 +180,7 @@ eeze_sensor_new(Eeze_Sensor_Type type)
|
||||||
if (module->read(sens->type, sens))
|
if (module->read(sens->type, sens))
|
||||||
return sens;
|
return sens;
|
||||||
|
|
||||||
|
free(sens);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,10 +84,12 @@ fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERR("Not possible to read from this sensor type.");
|
ERR("Not possible to read from this sensor type.");
|
||||||
|
free(obj);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
|
memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
|
||||||
|
free(obj);
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -132,8 +134,10 @@ fake_async_read(Eeze_Sensor_Type sensor_type, void *user_data EINA_UNUSED)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERR("Not possible to set a callback for this sensor type.");
|
ERR("Not possible to set a callback for this sensor type.");
|
||||||
|
free(obj);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
free(obj);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -615,11 +615,12 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERR("Not possible to read from this sensor type.");
|
ERR("Not possible to read from this sensor type.");
|
||||||
|
free(obj);
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
|
memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
|
||||||
|
free(obj);
|
||||||
sensor_stop(sensor_handle, type);
|
sensor_stop(sensor_handle, type);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue