cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=b2fb58b91595938722be37e131c67228235a82bf

commit b2fb58b91595938722be37e131c67228235a82bf
Author: Jean Guyomarc'h <jean.guyoma...@gmail.com>
Date:   Mon Oct 12 12:04:38 2015 -0700

    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 <ced...@osg.samsung.com>
---
 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)

-- 


Reply via email to