From 1c0a459293981ef9691b9bb5acd468ba84e502b4 Mon Sep 17 00:00:00 2001 From: Ali Alzyod Date: Mon, 29 Jul 2019 12:10:18 +0200 Subject: [PATCH] efl_gfx_color: fix color_code_set Summary: There are two parts for this patch: 1- Fix sigmentation fault when using (efl_gfx_color_color_code_set). // It try to modify const variable 2- Remove unnecessary code. // why would user pass slash or back slash as color code format. Test Plan: ``` #define EFL_EO_API_SUPPORT 1 #define EFL_BETA_API_SUPPORT 1 #include #include #include static void _gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) { efl_exit(0); } static void _gui_setup() { Eo *win, *rect; win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC), efl_text_set(efl_added, "Hello World"), efl_ui_win_autodel_set(efl_added, EINA_TRUE)); // when the user clicks "close" on a window there is a request to delete efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, NULL); rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS,win); const char *color = "#FF0000FF"; efl_gfx_color_code_set(rect,color); evas_object_resize(rect,250,250); evas_object_resize(win,250,250); evas_object_move(rect,0,0); evas_object_show(rect); evas_object_show(win); } EAPI_MAIN void efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) { _gui_setup(); } EFL_MAIN() ``` Reviewers: zmike, cedric, segfaultxavi, woohyun Reviewed By: segfaultxavi Subscribers: singh.amitesh, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9422 --- src/lib/efl/interfaces/efl_gfx_color.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_color.c b/src/lib/efl/interfaces/efl_gfx_color.c index 92c1f07483..fe35d92cc7 100644 --- a/src/lib/efl/interfaces/efl_gfx_color.c +++ b/src/lib/efl/interfaces/efl_gfx_color.c @@ -1,24 +1,6 @@ #include "config.h" #include "Efl.h" -static int -_format_clean_param(Eina_Tmpstr *s) -{ - Eina_Tmpstr *ss; - char *ds; - int len = 0; - - ds = (char*) s; - for (ss = s; *ss; ss++, ds++, len++) - { - if ((*ss == '\\') && *(ss + 1)) ss++; - if (ds != ss) *ds = *ss; - } - *ds = 0; - - return len; -} - static int _hex_string_get(char ch, Eina_Bool *ok) { @@ -102,7 +84,7 @@ _efl_gfx_color_color_code_set(Eo *obj, void *_pd EINA_UNUSED, const char *colorc int len; unsigned char r, g, b, a; - len = _format_clean_param(colorcode); + len = (size_t) strlen(colorcode); _format_color_parse(colorcode, len, &r, &g, &b, &a); efl_gfx_color_set(obj, r, g, b, a);