[recipes] Don't leak memory



commit a9ed446af2fa3750fc97613c21fa586380b6b6df
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Mar 28 21:52:36 2017 +0100

    Don't leak memory
    
    We need to free the duplicated strings in populate_cuisine_combo.
    A g_autofree can take care of it.

 src/gr-edit-page.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/gr-edit-page.c b/src/gr-edit-page.c
index 1e786e8..d6c023b 100644
--- a/src/gr-edit-page.c
+++ b/src/gr-edit-page.c
@@ -368,7 +368,6 @@ populate_cuisine_combo (GrEditPage *page)
 {
         g_autofree char **names = NULL;
         guint length;
-        const char *title;
         int i;
         GrRecipeStore *store;
 
@@ -377,9 +376,12 @@ populate_cuisine_combo (GrEditPage *page)
         gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (page->cuisine_combo));
 
         for (i = 0; i < length; ++i) {
-                char *temp_cuisine_name;
+                g_autofree char *temp_cuisine_name = NULL;
+
                 temp_cuisine_name = g_strstrip (g_strdup (names[i]));
                 if (strcmp (temp_cuisine_name, "") != 0) {
+                        const char *title;
+
                         gr_cuisine_get_data (temp_cuisine_name, &title, NULL, NULL);
                         gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (page->cuisine_combo),
                                                                        temp_cuisine_name, title);


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