princeamd pushed a commit to branch enlightenment-0.17.

commit 162c86ce550aeeed69bd62b45d857da454f97cf8
Author: Chris Michael <[email protected]>
Date:   Mon May 20 10:27:16 2013 +0100

    Backport: 10acf59 :: Fix potential memleaks reported by klockwork.
    
    Signed-off-by: Chris Michael <[email protected]>
    Signed-off-by: Deon Thomas <[email protected]>
---
 src/modules/conf_randr/e_smart_monitor.c | 10 +++++-----
 src/modules/conf_randr/e_smart_randr.c   | 20 +++++++++++++-------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/modules/conf_randr/e_smart_monitor.c 
b/src/modules/conf_randr/e_smart_monitor.c
index f22ef98..fb737c2 100644
--- a/src/modules/conf_randr/e_smart_monitor.c
+++ b/src/modules/conf_randr/e_smart_monitor.c
@@ -2401,11 +2401,10 @@ _e_smart_monitor_crtc_find(Ecore_X_Randr_Output output)
              int j = 0;
 
              /* get any outputs on this crtc */
-             outputs = 
-               ecore_x_randr_crtc_outputs_get(root, crtcs[i], &noutputs);
-
-             /* if this crtc has no outputs, we can use it */
-             if ((!outputs) || (noutputs == 0))
+             if (!(outputs = 
+                   ecore_x_randr_crtc_outputs_get(root, crtcs[i], &noutputs)))
+               ret = crtcs[i];
+             else if (noutputs == 0)
                ret = crtcs[i];
              else
                {
@@ -2421,6 +2420,7 @@ _e_smart_monitor_crtc_find(Ecore_X_Randr_Output output)
                     }
                }
 
+             free(outputs);
              if (ret) break;
           }
 
diff --git a/src/modules/conf_randr/e_smart_randr.c 
b/src/modules/conf_randr/e_smart_randr.c
index e885839..139a675 100644
--- a/src/modules/conf_randr/e_smart_randr.c
+++ b/src/modules/conf_randr/e_smart_randr.c
@@ -806,8 +806,14 @@ 
_e_smart_randr_monitor_preferred_mode_size_get(Ecore_X_Randr_Output output, Evas
 
    root = ecore_x_window_root_first_get();
 
-   modes = ecore_x_randr_output_modes_get(root, output, &n, &p);
-   if ((!modes) || (n == 0)) return;
+   if (!(modes = ecore_x_randr_output_modes_get(root, output, &n, &p)))
+     return;
+
+   if (n == 0)
+     {
+        if (modes) free(modes);
+        return;
+     }
 
    ecore_x_randr_mode_size_get(root, modes[p - 1], mw, mh);
 
@@ -886,11 +892,10 @@ _e_smart_randr_crtc_find(Ecore_X_Randr_Output output)
              int j = 0;
 
              /* get any outputs on this crtc */
-             outputs = 
-               ecore_x_randr_crtc_outputs_get(root, crtcs[i], &noutputs);
-
-             /* if this crtc has no outputs, we can use it */
-             if ((!outputs) || (noutputs == 0))
+             if (!(outputs = 
+                   ecore_x_randr_crtc_outputs_get(root, crtcs[i], &noutputs)))
+               ret = crtcs[i];
+             else if (noutputs == 0)
                ret = crtcs[i];
              else
                {
@@ -906,6 +911,7 @@ _e_smart_randr_crtc_find(Ecore_X_Randr_Output output)
                     }
                }
 
+             free(outputs);
              if (ret) break;
           }
 

-- 

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

Build for Windows Store.

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

Reply via email to