[grilo-plugins] gravatar: Always free the GMatchInfo from g_regex_match()



commit 1279ea98e4c29180050330ab324f71051ec39831
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Mon Sep 18 11:08:29 2017 +0200

    gravatar: Always free the GMatchInfo from g_regex_match()
    
    The API doc is explicit about it:
    «  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/gravatar/grl-gravatar.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/gravatar/grl-gravatar.c b/src/gravatar/grl-gravatar.c
index 27cffbd..bf615f5 100644
--- a/src/gravatar/grl-gravatar.c
+++ b/src/gravatar/grl-gravatar.c
@@ -217,12 +217,12 @@ get_avatar (const gchar *field) {
 
   if (g_regex_match (email_regex, lowercased_field, 0, &match_info)) {
     email = g_match_info_fetch (match_info, 0);
-    g_match_info_free (match_info);
     email_hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, email, -1);
     avatar = g_strdup_printf (GRAVATAR_URL, email_hash);
     g_free (email);
     g_free (email_hash);
   }
+  g_match_info_free (match_info);
 
   return avatar;
 }


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