summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-07-19 15:44:58 -0400
committerCedric BAIL <cedric.bail@free.fr>2019-07-19 15:05:00 -0700
commitdc1630d49668acc305538fb4ec3fc433fb79d54e (patch)
tree86081cb7c3f6bf4f3f8e528456f00423844727e6
parent17f433c57bfa11319a22fde1aedb21e99a3a1268 (diff)
evas: fix type checking of Evas pointers in legacy functions
many of these functions go directly to evas internals with no eo checks, and the existing "MAGIC_CHECK" macro has somehow become a useless null check type checking here is important in order to avoid crazy behavior when the wrong object types are passed @fix Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9364
-rw-r--r--src/lib/evas/canvas/evas_main.c47
-rw-r--r--src/lib/evas/canvas/evas_render.c2
-rw-r--r--src/lib/evas/include/evas_private.h12
3 files changed, 29 insertions, 32 deletions
diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index 84854cddf7..d246bdc60b 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -357,9 +357,8 @@ _evas_canvas_efl_object_constructor(Eo *eo_obj, Evas_Public_Data *e)
357EAPI void 357EAPI void
358evas_free(Evas *eo_e) 358evas_free(Evas *eo_e)
359{ 359{
360 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 360 if (!eo_e) return;
361 return; 361 EVAS_TYPE_CHECK(eo_e);
362 MAGIC_CHECK_END();
363 if (efl_parent_get(eo_e)) 362 if (efl_parent_get(eo_e))
364 efl_del(eo_e); 363 efl_del(eo_e);
365 else 364 else
@@ -1230,9 +1229,7 @@ _evas_canvas_efl_canvas_scene_image_max_size_get(const Eo *eo_e EINA_UNUSED, Eva
1230EAPI void 1229EAPI void
1231evas_output_framespace_set(Evas *eo_e, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) 1230evas_output_framespace_set(Evas *eo_e, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1232{ 1231{
1233 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 1232 EVAS_TYPE_CHECK(eo_e);
1234 return;
1235 MAGIC_CHECK_END();
1236 1233
1237 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 1234 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
1238 1235
@@ -1251,9 +1248,7 @@ evas_output_framespace_set(Evas *eo_e, Evas_Coord x, Evas_Coord y, Evas_Coord w,
1251EAPI void 1248EAPI void
1252evas_output_framespace_get(const Evas *eo_e, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) 1249evas_output_framespace_get(const Evas *eo_e, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1253{ 1250{
1254 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 1251 EVAS_TYPE_CHECK(eo_e);
1255 return;
1256 MAGIC_CHECK_END();
1257 1252
1258 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 1253 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
1259 1254
@@ -1266,9 +1261,7 @@ evas_output_framespace_get(const Evas *eo_e, Evas_Coord *x, Evas_Coord *y, Evas_
1266EAPI void 1261EAPI void
1267evas_output_method_set(Evas *eo_e, int render_method) 1262evas_output_method_set(Evas *eo_e, int render_method)
1268{ 1263{
1269 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 1264 EVAS_TYPE_CHECK(eo_e);
1270 return;
1271 MAGIC_CHECK_END();
1272 1265
1273 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 1266 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
1274 1267
@@ -1340,9 +1333,7 @@ evas_output_method_set(Evas *eo_e, int render_method)
1340EAPI int 1333EAPI int
1341evas_output_method_get(const Evas *eo_e) 1334evas_output_method_get(const Evas *eo_e)
1342{ 1335{
1343 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 1336 EVAS_TYPE_CHECK(eo_e, RENDER_METHOD_INVALID);
1344 return RENDER_METHOD_INVALID;
1345 MAGIC_CHECK_END();
1346 1337
1347 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 1338 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
1348 1339
@@ -1352,9 +1343,7 @@ evas_output_method_get(const Evas *eo_e)
1352EAPI void 1343EAPI void
1353evas_output_size_set(Evas *eo_e, int w, int h) 1344evas_output_size_set(Evas *eo_e, int w, int h)
1354{ 1345{
1355 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 1346 EVAS_TYPE_CHECK(eo_e);
1356 return;
1357 MAGIC_CHECK_END();
1358 1347
1359 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 1348 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
1360 1349
@@ -1382,9 +1371,7 @@ evas_output_size_set(Evas *eo_e, int w, int h)
1382EAPI void 1371EAPI void
1383evas_output_size_get(const Evas *eo_e, int *w, int *h) 1372evas_output_size_get(const Evas *eo_e, int *w, int *h)
1384{ 1373{
1385 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 1374 EVAS_TYPE_CHECK(eo_e);
1386 return;
1387 MAGIC_CHECK_END();
1388 1375
1389 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 1376 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
1390 1377
@@ -1395,9 +1382,7 @@ evas_output_size_get(const Evas *eo_e, int *w, int *h)
1395EAPI void 1382EAPI void
1396evas_output_viewport_set(Evas *eo_e, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) 1383evas_output_viewport_set(Evas *eo_e, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1397{ 1384{
1398 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 1385 EVAS_TYPE_CHECK(eo_e);
1399 return;
1400 MAGIC_CHECK_END();
1401 1386
1402 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 1387 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
1403 1388
@@ -1425,9 +1410,7 @@ evas_output_viewport_set(Evas *eo_e, Evas_Coord x, Evas_Coord y, Evas_Coord w, E
1425EAPI void 1410EAPI void
1426evas_output_viewport_get(const Evas *eo_e, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) 1411evas_output_viewport_get(const Evas *eo_e, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1427{ 1412{
1428 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 1413 EVAS_TYPE_CHECK(eo_e);
1429 return;
1430 MAGIC_CHECK_END();
1431 1414
1432 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 1415 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
1433 1416
@@ -1961,9 +1944,7 @@ evas_font_hinting_can_hint(const Evas *eo_e, Evas_Font_Hinting_Flags hinting)
1961EAPI void 1944EAPI void
1962evas_font_available_list_free(Evas *eo_e, Eina_List *available) 1945evas_font_available_list_free(Evas *eo_e, Eina_List *available)
1963{ 1946{
1964 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 1947 EVAS_TYPE_CHECK(eo_e);
1965 return;
1966 MAGIC_CHECK_END();
1967 1948
1968 evas_font_dir_available_list_free(available); 1949 evas_font_dir_available_list_free(available);
1969} 1950}
@@ -1978,7 +1959,7 @@ _evas_canvas_efl_canvas_scene_group_objects_calculate(Eo *eo_e, Evas_Public_Data
1978EAPI void 1959EAPI void
1979evas_smart_objects_calculate(Eo *eo_e) 1960evas_smart_objects_calculate(Eo *eo_e)
1980{ 1961{
1981 EINA_SAFETY_ON_NULL_RETURN(eo_e); 1962 EVAS_TYPE_CHECK(eo_e);
1982 evas_call_smarts_calculate(eo_e); 1963 evas_call_smarts_calculate(eo_e);
1983} 1964}
1984 1965
@@ -1991,6 +1972,7 @@ _evas_canvas_efl_canvas_scene_group_objects_calculating_get(const Eo *eo_e EINA_
1991EAPI Eina_Bool 1972EAPI Eina_Bool
1992evas_smart_objects_calculating_get(const Eo *obj) 1973evas_smart_objects_calculating_get(const Eo *obj)
1993{ 1974{
1975 EVAS_TYPE_CHECK(obj, EINA_FALSE);
1994 return efl_canvas_scene_group_objects_calculating_get(obj); 1976 return efl_canvas_scene_group_objects_calculating_get(obj);
1995} 1977}
1996 1978
@@ -2004,18 +1986,21 @@ _evas_canvas_smart_objects_calculate_count_get(const Eo *eo_e EINA_UNUSED, Evas_
2004EAPI Eina_Bool 1986EAPI Eina_Bool
2005evas_pointer_inside_get(const Evas *obj) 1987evas_pointer_inside_get(const Evas *obj)
2006{ 1988{
1989 EVAS_TYPE_CHECK(obj, EINA_FALSE);
2007 return efl_canvas_pointer_inside_get(obj, NULL); 1990 return efl_canvas_pointer_inside_get(obj, NULL);
2008} 1991}
2009 1992
2010EAPI Eina_Bool 1993EAPI Eina_Bool
2011evas_pointer_inside_by_device_get(const Evas *obj, Eo *dev) 1994evas_pointer_inside_by_device_get(const Evas *obj, Eo *dev)
2012{ 1995{
1996 EVAS_TYPE_CHECK(obj, EINA_FALSE);
2013 return efl_canvas_pointer_inside_get(obj, dev); 1997 return efl_canvas_pointer_inside_get(obj, dev);
2014} 1998}
2015 1999
2016EAPI Eina_List* 2000EAPI Eina_List*
2017evas_objects_at_xy_get(Eo *eo_e, int x, int y, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects) 2001evas_objects_at_xy_get(Eo *eo_e, int x, int y, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects)
2018{ 2002{
2003 EVAS_TYPE_CHECK(eo_e, NULL);
2019 return _efl_canvas_evas_canvas_objects_at_xy_get_helper(eo_e, efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS), x, y, include_pass_events_objects, include_hidden_objects); 2004 return _efl_canvas_evas_canvas_objects_at_xy_get_helper(eo_e, efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS), x, y, include_pass_events_objects, include_hidden_objects);
2020} 2005}
2021/* Internal EO APIs */ 2006/* Internal EO APIs */
diff --git a/src/lib/evas/canvas/evas_render.c b/src/lib/evas/canvas/evas_render.c
index 074dc1d618..0a8d8a6748 100644
--- a/src/lib/evas/canvas/evas_render.c
+++ b/src/lib/evas/canvas/evas_render.c
@@ -2864,7 +2864,7 @@ evas_render_pre(Evas *eo_e, Evas_Public_Data *evas)
2864EAPI void 2864EAPI void
2865evas_render_pending_objects_flush(Evas *eo_e) 2865evas_render_pending_objects_flush(Evas *eo_e)
2866{ 2866{
2867 Evas_Public_Data *evas = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); 2867 Evas_Public_Data *evas = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS);
2868 EINA_SAFETY_ON_NULL_RETURN(evas); 2868 EINA_SAFETY_ON_NULL_RETURN(evas);
2869 evas_render_pre(eo_e, evas); 2869 evas_render_pre(eo_e, evas);
2870} 2870}
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 751f81cd07..2c6dcdd990 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -517,7 +517,19 @@ OPAQUE_TYPE(Evas_Font_Instance); /* General type for RGBA_Font_Int */
517#define MAGIC_MAP 0x7575177d 517#define MAGIC_MAP 0x7575177d
518#define MAGIC_DEV 0x7d773738 518#define MAGIC_DEV 0x7d773738
519 519
520#define EVAS_TYPE_CHECK(obj, ...) \
521 do { \
522 if (!efl_isa((obj), EVAS_CANVAS_CLASS)) \
523 { \
524 CRI("non-Evas passed to %s", __func__); \
525 return __VA_ARGS__; \
526 } \
527 } \
528 while (0)
529
520#ifdef EINA_MAGIC_DEBUG 530#ifdef EINA_MAGIC_DEBUG
531
532
521# define MAGIC_CHECK_FAILED(o, t, m) \ 533# define MAGIC_CHECK_FAILED(o, t, m) \
522{evas_debug_error(); \ 534{evas_debug_error(); \
523 if (!o) evas_debug_input_null(); \ 535 if (!o) evas_debug_input_null(); \