princeamd pushed a commit to branch enlightenment-0.17.

commit 674b6a99984e0bd6815282bead1797da68844cc5
Author: Chris Michael <[email protected]>
Date:   Mon May 20 10:22:27 2013 +0100

    Backport: dff4df5 :: Fix potential memleak reported by klockwork.
    
    Signed-off-by: Chris Michael <[email protected]>
    Signed-off-by: Deon Thomas <[email protected]>
---
 src/bin/e_randr.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/bin/e_randr.c b/src/bin/e_randr.c
index fb7bf98..180ceec 100644
--- a/src/bin/e_randr.c
+++ b/src/bin/e_randr.c
@@ -989,8 +989,15 @@ _e_randr_config_output_crtc_find(E_Randr_Output_Config 
*cfg)
    root = ecore_x_window_root_first_get();
 
    /* get a list of possible crtcs for this output */
-   possible = ecore_x_randr_output_possible_crtcs_get(root, cfg->xid, &num);
-   if ((!possible) || (num == 0)) return NULL;
+   if (!(possible = 
+         ecore_x_randr_output_possible_crtcs_get(root, cfg->xid, &num)))
+     return NULL;
+
+   if (num == 0)
+     {
+        if (possible) free(possible);
+        return NULL;
+     }
 
    /* loop the possible crtcs */
    for (i = 0; i < num; i++)
@@ -1031,8 +1038,14 @@ 
_e_randr_config_output_preferred_mode_get(E_Randr_Output_Config *cfg)
    root = ecore_x_window_root_first_get();
 
    /* get the list of modes for this output */
-   modes = ecore_x_randr_output_modes_get(root, cfg->xid, &n, &p);
-   if ((!modes) || (n == 0)) return 0;
+   if (!(modes = ecore_x_randr_output_modes_get(root, cfg->xid, &n, &p)))
+     return 0;
+
+   if (n == 0)
+     {
+        if (modes) free(modes);
+        return 0;
+     }
 
    mode = modes[p - 1];
    free(modes);

-- 

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Reply via email to