summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2016-05-20 11:47:32 +0100
committerTom Hacohen <tom@stosb.com>2016-05-20 11:47:32 +0100
commit5e95d7f2d83c1e107e44c60f1d6c27843ce280a7 (patch)
tree1139311ac8beab1f3fe92957c6b88c69bd726f51
parent5f46df619b7cf52649b94b9b03098b0f259d2a30 (diff)
Eo super: Validate class in eo_super instead of call_reslove.
This is more correct and fixes a segfault that occurs when eo_id is disabled.
-rw-r--r--src/lib/eo/eo.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index cef7bb797c..a8dde5f11a 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -253,15 +253,17 @@ _eo_kls_itr_next(const _Eo_Class *orig_kls, const _Eo_Class *cur_klass, Eo_Op op
253 253
254/************************************ EO ************************************/ 254/************************************ EO ************************************/
255 255
256static const Eo_Class *_super_class = NULL; 256static const _Eo_Class *_super_class = NULL;
257static Eina_Spinlock _super_class_lock; 257static Eina_Spinlock _super_class_lock;
258 258
259EAPI Eo * 259EAPI Eo *
260eo_super(const Eo *obj, const Eo_Class *cur_klass) 260eo_super(const Eo *obj, const Eo_Class *cur_klass)
261{ 261{
262 EO_CLASS_POINTER_RETURN_VAL(cur_klass, klass, NULL);
263
262 /* FIXME: Switch to atomic operations intead of lock. */ 264 /* FIXME: Switch to atomic operations intead of lock. */
263 eina_spinlock_take(&_super_class_lock); 265 eina_spinlock_take(&_super_class_lock);
264 _super_class = cur_klass; 266 _super_class = klass;
265 267
266 return (Eo *) ((Eo_Id) obj | MASK_SUPER_TAG); 268 return (Eo *) ((Eo_Id) obj | MASK_SUPER_TAG);
267} 269}
@@ -279,18 +281,11 @@ _eo_call_resolve(Eo *eo_id, const char *func_name, Eo_Op_Call_Data *call, Eo_Cal
279 281
280 if (((Eo_Id) eo_id) & MASK_SUPER_TAG) 282 if (((Eo_Id) eo_id) & MASK_SUPER_TAG)
281 { 283 {
282 const Eo_Class *tmp = _super_class; 284 cur_klass = _super_class;
283 _super_class = NULL; 285 _super_class = NULL;
284 eina_spinlock_release(&_super_class_lock); 286 eina_spinlock_release(&_super_class_lock);
285 287
286 eo_id = (Eo *) ((Eo_Id) eo_id & ~MASK_SUPER_TAG); 288 eo_id = (Eo *) ((Eo_Id) eo_id & ~MASK_SUPER_TAG);
287
288 cur_klass = _eo_class_pointer_get(tmp);
289 if (!cur_klass)
290 {
291 ERR("Invalid super class found. Aborting.");
292 return EINA_FALSE;
293 }
294 } 289 }
295 290
296 if (EINA_UNLIKELY(!eo_id)) 291 if (EINA_UNLIKELY(!eo_id))