summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-12 19:13:55 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-12 19:14:13 +0100
commit54eac123c2f7e74675a0a4fa06fe0f02173141c5 (patch)
tree4b38d46562c82a566d0e9b253c2e6a73f770fe59
parent082ebac3e3c315ca1e1437029658b630137d3bee (diff)
eolian: correctly validate function pointers
-rw-r--r--src/lib/eolian/database_validate.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index c5b3664201..c3e7887a37 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -64,6 +64,9 @@ static Eina_Bool _validate_expr(const Eolian_Unit *src,
64 Eolian_Expression *expr, 64 Eolian_Expression *expr,
65 const Eolian_Type *tp, 65 const Eolian_Type *tp,
66 Eolian_Expression_Mask msk); 66 Eolian_Expression_Mask msk);
67static Eina_Bool _validate_function(const Eolian_Unit *src,
68 Eolian_Function *func,
69 Eina_Hash *nhash);
67 70
68typedef struct _Cb_Ret 71typedef struct _Cb_Ret
69{ 72{
@@ -145,7 +148,8 @@ _validate_typedecl(const Eolian_Unit *src, Eolian_Typedecl *tp)
145 return _validate(&tp->base); 148 return _validate(&tp->base);
146 } 149 }
147 case EOLIAN_TYPEDECL_FUNCTION_POINTER: 150 case EOLIAN_TYPEDECL_FUNCTION_POINTER:
148 // FIXME validate functions here 151 if (!_validate_function(src, tp->function_pointer, NULL))
152 return EINA_FALSE;
149 return _validate(&tp->base); 153 return _validate(&tp->base);
150 default: 154 default:
151 return EINA_FALSE; 155 return EINA_FALSE;
@@ -172,7 +176,6 @@ static Eina_Bool
172_validate_type(const Eolian_Unit *src, Eolian_Type *tp) 176_validate_type(const Eolian_Unit *src, Eolian_Type *tp)
173{ 177{
174 char buf[256]; 178 char buf[256];
175
176 if (tp->owned && !database_type_is_ownable(src, tp)) 179 if (tp->owned && !database_type_is_ownable(src, tp))
177 { 180 {
178 snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->full_name); 181 snprintf(buf, sizeof(buf), "type '%s' is not ownable", tp->full_name);
@@ -326,7 +329,7 @@ _validate_function(const Eolian_Unit *src, Eolian_Function *func, Eina_Hash *nha
326 else _duplicates_warn = atoi(s); 329 else _duplicates_warn = atoi(s);
327 } 330 }
328 331
329 const Eolian_Function *ofunc = eina_hash_find(nhash, func->name); 332 const Eolian_Function *ofunc = nhash ? eina_hash_find(nhash, func->name) : NULL;
330 if (EINA_UNLIKELY(ofunc && (_duplicates_warn > 0))) 333 if (EINA_UNLIKELY(ofunc && (_duplicates_warn > 0)))
331 { 334 {
332 snprintf(buf, sizeof(buf), 335 snprintf(buf, sizeof(buf),
@@ -377,7 +380,7 @@ _validate_function(const Eolian_Unit *src, Eolian_Function *func, Eina_Hash *nha
377 return EINA_FALSE; 380 return EINA_FALSE;
378 381
379 /* just for now, when dups become errors there will be no need to check */ 382 /* just for now, when dups become errors there will be no need to check */
380 if (!ofunc) 383 if (!ofunc && nhash)
381 eina_hash_add(nhash, func->name, func); 384 eina_hash_add(nhash, func->name, func);
382 385
383 return _validate(&func->base); 386 return _validate(&func->base);