hermet pushed a commit to branch master.

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

commit c27b511b28d24ad07cb28cf84e56c475b83603e4
Author: Thiep Ha <thiep...@samsung.com>
Date:   Thu Dec 18 09:17:03 2014 +0900

    edje: fix memory leak in epp
    
    Summary:
    Variable include_defaults can be allocated and
    go out of scope without freeing it.
    
    Reviewers: cedric, seoz, woohyun, Hermet
    
    Reviewed By: Hermet
    
    Differential Revision: https://phab.enlightenment.org/D1784
---
 src/bin/edje/epp/cpplib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/bin/edje/epp/cpplib.c b/src/bin/edje/epp/cpplib.c
index 0659000..10ab5d8 100644
--- a/src/bin/edje/epp/cpplib.c
+++ b/src/bin/edje/epp/cpplib.c
@@ -5686,6 +5686,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
    char               *p;
    int                 f;
    cpp_buffer         *fp;
+   char               *epath = 0;
 
    /* The code looks at the defaults through this pointer, rather than through
     * the constant structure above.  This pointer gets changed if an 
environment
@@ -5833,8 +5834,6 @@ push_parse_file(cpp_reader * pfile, const char *fname)
 
    {                           /* read the appropriate environment variable 
and if it exists
                                 * replace include_defaults with the listed 
path. */
-      char               *epath = 0;
-
       switch ((opts->objc << 1) + opts->cplusplus)
        {
        case 0:
@@ -6008,6 +6007,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
             if (fd < 0)
               {
                  cpp_perror_with_name(pfile, pend->arg);
+          if (epath) free(include_defaults);
                  return FATAL_EXIT_CODE;
               }
             cpp_push_buffer(pfile, NULL, 0);
@@ -6153,6 +6153,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
               {
                  cpp_perror_with_name(pfile, pend->arg);
                   if (f) close(f);
+          if (epath) free(include_defaults);
                  return FATAL_EXIT_CODE;
               }
             cpp_push_buffer(pfile, NULL, 0);
@@ -6173,6 +6174,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
 
    if (finclude(pfile, f, fname, 0, NULL))
       output_line_command(pfile, 0, same_file);
+   if (epath) free(include_defaults);
    return SUCCESS_EXIT_CODE;
 }
 

-- 


Reply via email to