[xchat-gnome/gnome-3-0] fix mem leak. based on patch from https://bugs.launchpad.net/launchpad-integration/+bug/483610



commit 8697747dacdba4fc28e3e2bf3d5c7ceb0e6a079a
Author: Ritesh Khadgaray <khadgaray gmail com>
Date:   Fri Apr 1 15:17:29 2011 +0530

    fix mem leak.
    based on patch from https://bugs.launchpad.net/launchpad-integration/+bug/483610

 plugins/autoaway/xscreensaver.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/plugins/autoaway/xscreensaver.c b/plugins/autoaway/xscreensaver.c
index c73fe46..d2c2900 100644
--- a/plugins/autoaway/xscreensaver.c
+++ b/plugins/autoaway/xscreensaver.c
@@ -22,6 +22,18 @@
 #include "autoaway.h"
 #include "xscreensaver.h"
 
+static gboolean
+have_program_in_path (const char *name)
+{
+    gchar *path = g_find_program_in_path(name);
+    if(path)
+    {
+        g_free(path);
+        return TRUE;
+    }
+    return FALSE;
+}
+
 /* Use xprop to find out if screensaver is on or off */
 static gboolean
 get_screensaver_running_xprop (void)
@@ -73,8 +85,8 @@ get_screensaver_running_xs_cmd (void)
 gboolean
 get_xss_has_ipc (void)
 {
-	if (g_find_program_in_path ("xprop") ||
-	    g_find_program_in_path ("xscreensaver-command"))
+	if (have_program_in_path ("xprop") ||
+	    have_program_in_path ("xscreensaver-command"))
 	    return TRUE;
 
 	return FALSE;
@@ -83,9 +95,9 @@ get_xss_has_ipc (void)
 gboolean
 get_xss_screensaver_active (void)
 {
-	if (g_find_program_in_path ("xprop"))
+	if (have_program_in_path ("xprop"))
 		return get_screensaver_running_xprop();
-	else if (g_find_program_in_path ("xscreensaver-command"))
+	else if (have_program_in_path ("xscreensaver-command"))
 		return get_screensaver_running_xs_cmd();
 	return FALSE;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]