devilhorns pushed a commit to branch master.

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

    Fix potential memleaks reported by klockwork.
    
    Signed-off-by: Chris Michael <[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;
           }
 

-- 

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d

Reply via email to