jpeg pushed a commit to branch master.

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

commit ecb40c64b5a37d353b75a690010ff8bc72252e4a
Author: Srivardhan Hebbar <sri.heb...@samsung.com>
Date:   Mon Nov 23 20:44:27 2015 +0900

    evas_fb: Handling memory leak on realloc failure.
    
    Summary:
    I thought its better to fail and return null if realloc fails than to
    continue. So returning by closing all openend file.
    
    Signed-off-by: Srivardhan Hebbar <sri.heb...@samsung.com>
    
    Reviewers: cedric, illogict
    
    Differential Revision: https://phab.enlightenment.org/D3232
---
 src/modules/evas/engines/fb/evas_fb_main.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/modules/evas/engines/fb/evas_fb_main.c 
b/src/modules/evas/engines/fb/evas_fb_main.c
index de6f65a..3b8b23b 100644
--- a/src/modules/evas/engines/fb/evas_fb_main.c
+++ b/src/modules/evas/engines/fb/evas_fb_main.c
@@ -341,7 +341,7 @@ fb_list_modes(unsigned int *num_return)
 {
    FILE *f;
    char line[256], label[256], value[256];
-   FB_Mode *modes = NULL;
+   FB_Mode *modes = NULL, *temp;
    int num;
    
    num = 0;
@@ -365,7 +365,15 @@ fb_list_modes(unsigned int *num_return)
                   int timings = 0;
                   
                   num++;
+                  temp = modes;
                   modes = realloc(modes, num * sizeof(FB_Mode));
+                  if (!modes)
+                    {
+                       free(temp);
+                       fclose(f);
+                       *num_return = 0;
+                       return NULL;
+                    }
                   memset(modes + (num - 1), 0, sizeof(FB_Mode));
                   modes[num - 1].width = atoi(f1);
                   modes[num - 1].height = atoi(f2);

-- 


Reply via email to