From b2fb58b91595938722be37e131c67228235a82bf Mon Sep 17 00:00:00 2001 From: Jean Guyomarc'h Date: Mon, 12 Oct 2015 12:04:38 -0700 Subject: [PATCH] edje_cc: fix segfault when a program attempts to play a non-registered sound Summary: When an edje program attempted to play a sound that was not registered (e.g. in a sounds{} block), edje_cc would segfault instead of throwing an error. @fix Reviewers: cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3171 Signed-off-by: Cedric BAIL --- src/bin/edje/edje_cc_handlers.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c index c214f5b..b96647a 100644 --- a/src/bin/edje/edje_cc_handlers.c +++ b/src/bin/edje/edje_cc_handlers.c @@ -12781,6 +12781,7 @@ st_collections_group_programs_program_action(void) Edje_Part_Collection *pc; Edje_Program *ep; int i; + Eina_Bool found = EINA_FALSE; pc = eina_list_data_get(eina_list_last(edje_collections)); if (sequencing) @@ -12828,16 +12829,22 @@ st_collections_group_programs_program_action(void) else if (ep->action == EDJE_ACTION_TYPE_SOUND_SAMPLE) { ep->sample_name = parse_str(1); - for (i = 0; i < (int)edje_file->sound_dir->samples_count; i++) + if (edje_file->sound_dir) { - if (!strcmp(edje_file->sound_dir->samples[i].name, ep->sample_name)) - break; - if (i == (int)(edje_file->sound_dir->samples_count - 1)) + for (i = 0; i < (int)edje_file->sound_dir->samples_count; i++) { - ERR("No Sample name %s exist.", ep->sample_name); - exit(-1); + if (!strcmp(edje_file->sound_dir->samples[i].name, ep->sample_name)) + { + found = EINA_TRUE; + break; + } } } + if (!found) + { + ERR("No Sample name %s exist.", ep->sample_name); + exit(-1); + } ep->speed = parse_float_range(2, 0.0, 100.0); if (get_arg_count() >= 4) ep->channel = parse_enum(3, @@ -12853,16 +12860,22 @@ st_collections_group_programs_program_action(void) else if (ep->action == EDJE_ACTION_TYPE_SOUND_TONE) { ep->tone_name = parse_str(1); - for (i = 0; i < (int)edje_file->sound_dir->tones_count; i++) + if (edje_file->sound_dir) { - if (!strcmp(edje_file->sound_dir->tones[i].name, ep->tone_name)) - break; - if (i == (int)(edje_file->sound_dir->tones_count - 1)) + for (i = 0; i < (int)edje_file->sound_dir->tones_count; i++) { - ERR("No Tone name %s exist.", ep->tone_name); - exit(-1); + if (!strcmp(edje_file->sound_dir->tones[i].name, ep->tone_name)) + { + found = EINA_TRUE; + break; + } } } + if (!found) + { + ERR("No Tone name %s exist.", ep->tone_name); + exit(-1); + } ep->duration = parse_float_range(2, 0.1, 10.0); } else if (ep->action == EDJE_ACTION_TYPE_VIBRATION_SAMPLE) -- 2.7.4