summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli <ali198724@gmail.com>2020-04-16 15:51:31 +0000
committerStefan Schmidt <s.schmidt@samsung.com>2020-04-17 11:14:57 +0200
commit7ac765c71b94c1124cb8d672960a12758747cad9 (patch)
treedb65d033ff6dfc6ac071db5213f09442f245f427
parentbc52776fd621e91fb013fbe31c0a5fdc0da3b20d (diff)
evas_textblock: prevent segfault if there are no style
``` #include <Elementary.h> EAPI_MAIN int elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) { Evas_Object *win, *textblock; elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); win = elm_win_util_standard_add("", ""); elm_win_autodel_set(win, EINA_TRUE); textblock = evas_object_textblock_add(win); evas_object_resize(textblock, 360, 360); evas_object_show(textblock); evas_object_textblock_text_markup_set(textblock, "<b>b</b>"); evas_object_resize(win, 360, 360); evas_object_show(win); elm_run(); return 0; } ELM_MAIN() ``` this application will crash. Any font format specified in text, if there are now style will cause the crash. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org> Differential Revision: https://phab.enlightenment.org/D11686
-rw-r--r--src/lib/evas/canvas/evas_font_dir.c3
-rw-r--r--src/tests/evas/evas_test_textblock.c17
2 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/evas/canvas/evas_font_dir.c b/src/lib/evas/canvas/evas_font_dir.c
index 533993f94a..18367fbb0a 100644
--- a/src/lib/evas/canvas/evas_font_dir.c
+++ b/src/lib/evas/canvas/evas_font_dir.c
@@ -187,6 +187,9 @@ evas_font_set_get(const char *name)
187 Eina_List *fonts = NULL; 187 Eina_List *fonts = NULL;
188 char *p; 188 char *p;
189 189
190 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
191 if (!*name) return NULL;
192
190 p = strchr(name, ','); 193 p = strchr(name, ',');
191 if (!p) 194 if (!p)
192 { 195 {
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index d3c575039d..d26b8fc7b9 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -3772,6 +3772,22 @@ EFL_START_TEST(evas_textblock_style)
3772} 3772}
3773EFL_END_TEST 3773EFL_END_TEST
3774 3774
3775/* Textblock functionality without style. */
3776EFL_START_TEST(evas_textblock_style_empty)
3777{
3778 Evas *evas;
3779 Evas_Object *txt;
3780 Evas_Coord w, h;
3781 evas = EVAS_TEST_INIT_EVAS();
3782 txt = evas_object_textblock_add(evas);
3783 evas_object_textblock_text_markup_set(txt, "<b></b>");
3784 evas_object_textblock_size_formatted_get(txt, &w, &h);
3785 ck_assert_int_eq(w, 0);
3786 ck_assert_int_eq(h, 0);
3787 evas_free(evas);
3788}
3789EFL_END_TEST
3790
3775/* Basic test for style user push/peek/pop. */ 3791/* Basic test for style user push/peek/pop. */
3776EFL_START_TEST(evas_textblock_style_user) 3792EFL_START_TEST(evas_textblock_style_user)
3777{ 3793{
@@ -5045,6 +5061,7 @@ void evas_test_textblock(TCase *tc)
5045 tcase_add_test(tc, evas_textblock_size); 5061 tcase_add_test(tc, evas_textblock_size);
5046 tcase_add_test(tc, evas_textblock_editing); 5062 tcase_add_test(tc, evas_textblock_editing);
5047 tcase_add_test(tc, evas_textblock_style); 5063 tcase_add_test(tc, evas_textblock_style);
5064 tcase_add_test(tc, evas_textblock_style_empty);
5048 tcase_add_test(tc, evas_textblock_style_user); 5065 tcase_add_test(tc, evas_textblock_style_user);
5049 tcase_add_test(tc, evas_textblock_evas); 5066 tcase_add_test(tc, evas_textblock_evas);
5050 tcase_add_test(tc, evas_textblock_text_getters); 5067 tcase_add_test(tc, evas_textblock_text_getters);