summaryrefslogtreecommitdiff
path: root/legacy/eeze
diff options
context:
space:
mode:
authorStefan Schmidt <stefan@datenfreihafen.org>2012-12-13 15:54:29 +0000
committerStefan Schmidt <stefan@datenfreihafen.org>2012-12-13 15:54:29 +0000
commitd13ca5705fc2cda06858db9889d4cab545fa001f (patch)
tree3c64f1d15c957f545502fd4ad27d13e4025fec13 /legacy/eeze
parentd0b3c4a96d4d9ec6fa6f8d71eec21cfdaaad2182 (diff)
eeze/sensor: Fix leaks when getting allocated data from obj_get
SVN revision: 80882
Diffstat (limited to 'legacy/eeze')
-rw-r--r--legacy/eeze/src/lib/eeze_sensor.c16
-rw-r--r--legacy/eeze/src/modules/eeze_sensor_fake.c4
-rw-r--r--legacy/eeze/src/modules/eeze_sensor_tizen.c3
3 files changed, 17 insertions, 6 deletions
diff --git a/legacy/eeze/src/lib/eeze_sensor.c b/legacy/eeze/src/lib/eeze_sensor.c
index 566c4c5d96..024f206b62 100644
--- a/legacy/eeze/src/lib/eeze_sensor.c
+++ b/legacy/eeze/src/lib/eeze_sensor.c
@@ -154,16 +154,21 @@ eeze_sensor_new(Eeze_Sensor_Type type)
154 Eeze_Sensor_Obj *sens; 154 Eeze_Sensor_Obj *sens;
155 Eeze_Sensor_Module *module = NULL; 155 Eeze_Sensor_Module *module = NULL;
156 156
157 sens = calloc(1, sizeof(Eeze_Sensor_Obj));
158 if (!sens) return NULL;
159
160 sens = eeze_sensor_obj_get(type); 157 sens = eeze_sensor_obj_get(type);
161 if (!sens) return NULL; 158 if (!sens) return NULL;
162 159
163 module = _highest_priority_module_get(); 160 module = _highest_priority_module_get();
164 if (!module) return EINA_FALSE; 161 if (!module)
162 {
163 free(sens);
164 return EINA_FALSE;
165 }
165 166
166 if (!module->read) return NULL; 167 if (!module->read)
168 {
169 free(sens);
170 return NULL;
171 }
167 172
168 /* The read is asynchronous here as we want to make sure that the sensor 173 /* The read is asynchronous here as we want to make sure that the sensor
169 * object has valid data when created. As we give back cached values we 174 * object has valid data when created. As we give back cached values we
@@ -175,6 +180,7 @@ eeze_sensor_new(Eeze_Sensor_Type type)
175 if (module->read(sens->type, sens)) 180 if (module->read(sens->type, sens))
176 return sens; 181 return sens;
177 182
183 free(sens);
178 return NULL; 184 return NULL;
179} 185}
180 186
diff --git a/legacy/eeze/src/modules/eeze_sensor_fake.c b/legacy/eeze/src/modules/eeze_sensor_fake.c
index ab2373d5be..2bb10c150f 100644
--- a/legacy/eeze/src/modules/eeze_sensor_fake.c
+++ b/legacy/eeze/src/modules/eeze_sensor_fake.c
@@ -84,10 +84,12 @@ fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
84 84
85 default: 85 default:
86 ERR("Not possible to read from this sensor type."); 86 ERR("Not possible to read from this sensor type.");
87 free(obj);
87 return EINA_FALSE; 88 return EINA_FALSE;
88 } 89 }
89 90
90 memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj)); 91 memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
92 free(obj);
91 93
92 return EINA_TRUE; 94 return EINA_TRUE;
93} 95}
@@ -132,8 +134,10 @@ fake_async_read(Eeze_Sensor_Type sensor_type, void *user_data EINA_UNUSED)
132 134
133 default: 135 default:
134 ERR("Not possible to set a callback for this sensor type."); 136 ERR("Not possible to set a callback for this sensor type.");
137 free(obj);
135 return EINA_FALSE; 138 return EINA_FALSE;
136 } 139 }
140 free(obj);
137 return EINA_TRUE; 141 return EINA_TRUE;
138} 142}
139 143
diff --git a/legacy/eeze/src/modules/eeze_sensor_tizen.c b/legacy/eeze/src/modules/eeze_sensor_tizen.c
index 29154883e5..55db220a1b 100644
--- a/legacy/eeze/src/modules/eeze_sensor_tizen.c
+++ b/legacy/eeze/src/modules/eeze_sensor_tizen.c
@@ -615,11 +615,12 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
615 615
616 default: 616 default:
617 ERR("Not possible to read from this sensor type."); 617 ERR("Not possible to read from this sensor type.");
618 free(obj);
618 return EINA_FALSE; 619 return EINA_FALSE;
619 } 620 }
620 621
621 memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj)); 622 memcpy(lobj, obj, sizeof(Eeze_Sensor_Obj));
622 623 free(obj);
623 sensor_stop(sensor_handle, type); 624 sensor_stop(sensor_handle, type);
624 return EINA_TRUE; 625 return EINA_TRUE;
625} 626}