[tracker/tracker-0.10] libtracker-extract: Do not leak GMatchInfo objects.



commit a3ca7194700cd1ba353673e3a360680d39be3141
Author: Ivan Frade <ivan frade gmail com>
Date:   Tue Sep 20 14:41:11 2011 +0300

    libtracker-extract: Do not leak GMatchInfo objects.
    
    Glib doc:
    A GMatchInfo structure, used to get information on the match,
    is stored in match_info if not NULL. Note that if match_info
    is not NULL then it is created even if the function returns FALSE,
     i.e. you must free it regardless if regular expression actually matched.

 src/libtracker-extract/tracker-xmp.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-extract/tracker-xmp.c b/src/libtracker-extract/tracker-xmp.c
index a0ed07f..bf625d2 100644
--- a/src/libtracker-extract/tracker-xmp.c
+++ b/src/libtracker-extract/tracker-xmp.c
@@ -153,9 +153,11 @@ gps_coordinate_dup (const gchar *coordinates)
 		g_free (deg);
 		g_free (min);
 		g_free (ref);
+                g_match_info_free (info);
 
 		return g_strdup_printf ("%f", r);
 	} else {
+                g_match_info_free (info);
 		return NULL;
 	}
 }
@@ -324,7 +326,7 @@ static gint
 get_region_counter (const gchar *path) 
 {
         static GRegex *regex = NULL;
-        GMatchInfo    *match_info;
+        GMatchInfo    *match_info = NULL;
         gchar         *match;
         gint           result;
         
@@ -333,6 +335,7 @@ get_region_counter (const gchar *path)
         }
 
         if (!g_regex_match (regex, path, 0, &match_info)) {
+                g_match_info_free (match_info);
                 return -1;
         }
 



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