From aefcb11444f6172b10129967956f3e6bde4dca04 Mon Sep 17 00:00:00 2001 From: Vitalii Vorobiov Date: Wed, 4 Nov 2015 13:58:58 +0900 Subject: [PATCH] Evas Text: avoid SIGSEV while ellipsis recalculation Summary: Fix Segmentation Fault when TEXT part getting resized and when it has some params (for example ellipsis). Fix T2640 @fix Test Plan: Refer to T2640 Reviewers: raster, Hermet, seoz, herdsman, cedric, reutskiy.v.v, NikaWhite Subscribers: stefan_schmidt, tasn, cedric Maniphest Tasks: T2640 Differential Revision: https://phab.enlightenment.org/D2944 --- src/lib/evas/canvas/evas_object_text.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c index 3e3e9ff..c066a40 100644 --- a/src/lib/evas/canvas/evas_object_text.c +++ b/src/lib/evas/canvas/evas_object_text.c @@ -879,21 +879,27 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Text_Data *o, Eina_Unicode *t /* FIXME: We shouldn't do anything. */ } - int cut = ENFN->font_last_up_to_pos(ENDT, - o->font, - &itr->text_props, - ellip_frame - (advance + l + r), - 0); - if (cut >= 0) + /* In case when we reach end of itr list, and have NULL */ + int cut = -1; + if (itr && (itr != end_ellip_it)) { - end_ellip_it->text_pos = itr->text_pos + cut; - end_ellip_it->visual_pos = itr->visual_pos + cut; - if (_layout_text_item_trim(obj, o, itr, cut, EINA_TRUE)) + cut = ENFN->font_last_up_to_pos(ENDT, + o->font, + &itr->text_props, + ellip_frame - (advance + l + r), + 0); + if (cut >= 0) { - itr = (Evas_Object_Text_Item *) EINA_INLIST_GET(itr)->next; + end_ellip_it->text_pos = itr->text_pos + cut; + end_ellip_it->visual_pos = itr->visual_pos + cut; + if (_layout_text_item_trim(obj, o, itr, cut, EINA_TRUE)) + { + itr = (Evas_Object_Text_Item *) EINA_INLIST_GET(itr)->next; + } } } + /* Remove the rest of the items */ while (itr) { -- 2.7.4