hermet pushed a commit to branch master.

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

commit d5c913c60b4f7234010800bed8fe4ddd15edbb80
Author: Hermet Park <hermetp...@gmail.com>
Date:   Mon Apr 9 11:14:07 2018 +0900

    edje: fix potential memory leak.
    
    next_token() requires free() for it's returned value and a string attribute
    Here logic didn't take care of the memory usage.
    
    @fix
---
 src/bin/edje/edje_cc_script.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/bin/edje/edje_cc_script.c b/src/bin/edje/edje_cc_script.c
index e17355c78b..657bf4fb96 100644
--- a/src/bin/edje/edje_cc_script.c
+++ b/src/bin/edje/edje_cc_script.c
@@ -64,7 +64,7 @@ static void
 code_parse_internal(Code *code)
 {
    Code_Symbol *sym = NULL, *func = NULL;
-   Token *token, *tmp;
+   Token *token, *tmp = NULL;
    char *begin = code->shared;
    char *end = begin + strlen(begin);
    char *body;
@@ -92,9 +92,18 @@ code_parse_internal(Code *code)
                        token = tmp;
                        break;
                     }
+
+                  if (tmp->str) free(tmp->str);
+                  free(tmp);
                }
           }
 
+        if (tmp)
+          {
+             if (tmp->str) free(tmp->str);
+             free(tmp);
+          }
+
         switch (token->type)
           {
            case TOKEN_TYPE_COLON:
@@ -176,6 +185,9 @@ code_parse_internal(Code *code)
                     }
                   if (!depth)
                     break;
+
+                  if (tmp->str) free(tmp->str);
+                  free(tmp);
                }
              if ((begin - 1) > body)
                {
@@ -204,6 +216,12 @@ code_parse_internal(Code *code)
         if (token->str)
           free(token->str);
         free(token);
+
+        if (tmp)
+          {
+             if (tmp->str) free(tmp->str);
+             free(tmp);
+          }
      }
 
    eina_array_free(name_stack);

-- 


Reply via email to