summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-07-17 13:08:58 -0400
committerCedric BAIL <cedric.bail@free.fr>2019-07-17 10:54:42 -0700
commitebcf5e0cd9688235609f95f33c366759eb66321d (patch)
tree4073c2e526380bc9564c7452bdcec56295a3c323
parent4016de252cc73ffccaf0f6f79a113bdbd94800f4 (diff)
efl_ui/box: avoid exploding stack with lots of subobjects
using alloca like this without any limits is dangerous, so switch to malloc here in such cases Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9341
-rw-r--r--src/lib/elementary/efl_ui_box_layout.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/elementary/efl_ui_box_layout.c b/src/lib/elementary/efl_ui_box_layout.c
index eede41e799..d45532d1fc 100644
--- a/src/lib/elementary/efl_ui_box_layout.c
+++ b/src/lib/elementary/efl_ui_box_layout.c
@@ -52,7 +52,16 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Efl_Ui_Box_Data *pd)
52 52
53 _efl_ui_container_layout_init(ui_box, box_calc); 53 _efl_ui_container_layout_init(ui_box, box_calc);
54 54
55 items = alloca(count * sizeof(*items)); 55 /* Item_Calc struct is currently 152 bytes.
56 * this is pretty big to be allocating a huge number of, and we don't want to explode the stack
57 */
58 if (count >= 500)
59 {
60 items = malloc(count * sizeof(*items));
61 EINA_SAFETY_ON_NULL_RETURN(items);
62 }
63 else
64 items = alloca(count * sizeof(*items));
56#ifdef DEBUG 65#ifdef DEBUG
57 memset(items, 0, count * sizeof(*items)); 66 memset(items, 0, count * sizeof(*items));
58#endif 67#endif
@@ -201,4 +210,5 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Efl_Ui_Box_Data *pd)
201 efl_gfx_hint_size_restricted_min_set(ui_box, EINA_SIZE2D(want[0], want[1])); 210 efl_gfx_hint_size_restricted_min_set(ui_box, EINA_SIZE2D(want[0], want[1]));
202 211
203 efl_event_callback_call(ui_box, EFL_PACK_EVENT_LAYOUT_UPDATED, NULL); 212 efl_event_callback_call(ui_box, EFL_PACK_EVENT_LAYOUT_UPDATED, NULL);
213 if (count >= 500) free(items);
204} 214}