eeze/sensor: Fix leaks when getting allocated data from obj_get

SVN revision: 80882
This commit is contained in:
Stefan Schmidt 2012-12-13 15:54:29 +00:00
parent d0b3c4a96d
commit d13ca5705f
3 changed files with 17 additions and 6 deletions

View File

@ -154,16 +154,21 @@ eeze_sensor_new(Eeze_Sensor_Type type)
Eeze_Sensor_Obj *sens;
Eeze_Sensor_Module *module = NULL;
sens = calloc(1, sizeof(Eeze_Sensor_Obj));
if (!sens) return NULL;
sens = eeze_sensor_obj_get(type);
if (!sens) return NULL;
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
* 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))
return sens;
free(sens);
return NULL;
}

View File

@ -84,10 +84,12 @@ fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
default:
ERR("Not possible to read from this sensor type.");
free(obj);
return EINA_FALSE;
}
memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
free(obj);
return EINA_TRUE;
}
@ -132,8 +134,10 @@ fake_async_read(Eeze_Sensor_Type sensor_type, void *user_data EINA_UNUSED)
default:
ERR("Not possible to set a callback for this sensor type.");
free(obj);
return EINA_FALSE;
}
free(obj);
return EINA_TRUE;
}

View File

@ -615,11 +615,12 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
default:
ERR("Not possible to read from this sensor type.");
free(obj);
return EINA_FALSE;
}
memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
free(obj);
sensor_stop(sensor_handle, type);
return EINA_TRUE;
}