[discident-glib] ean: Correct destructor used for retvals



commit 5ebea20fb18220abfd70390bedb5c406f39cc671
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Jul 13 11:18:32 2013 +0200

    ean: Correct destructor used for retvals
    
    The strings will be freed using g_free() not xmlFree() so make
    sure that the returned strings are allocated with glib.

 discident-glib/discident-ean-rl-glib.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/discident-glib/discident-ean-rl-glib.c b/discident-glib/discident-ean-rl-glib.c
index 8cbad69..6dd5a83 100644
--- a/discident-glib/discident-ean-rl-glib.c
+++ b/discident-glib/discident-ean-rl-glib.c
@@ -179,7 +179,7 @@ _rl_parse_lookup_response (const char  *response,
                           char       **ret_img_url)
 {
        xmlDocPtr doc;
-       xmlChar *title, *img_url;
+       xmlChar *prop;
 
        if (response == NULL)
                return FALSE;
@@ -197,16 +197,18 @@ _rl_parse_lookup_response (const char  *response,
                return FALSE;
        }
 
-       title = xmlGetProp (doc->children, (const xmlChar *) "title");
-       if (title == NULL) {
+       prop = xmlGetProp (doc->children, (const xmlChar *) "title");
+       if (prop == NULL) {
                xmlFreeDoc (doc);
                return FALSE;
        }
-       *ret_title = (char *) title;
+       *ret_title = g_strdup ((const char *) prop);
+       xmlFree (prop);
 
-       img_url = xmlGetProp (doc->children, (const xmlChar *) "imageUrl");
-       if (ret_img_url != NULL)
-               *ret_img_url = (char *) img_url;
+       prop = xmlGetProp (doc->children, (const xmlChar *) "imageUrl");
+       if (prop != NULL)
+               *ret_img_url = g_strdup ((const char *) prop);
+       xmlFree (prop);
 
        xmlFreeDoc (doc);
 


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