[PATCH 14/14] Fix memory leaks found by cppcheck.



---
 libyelp/yelp-location-entry.c |   10 +++++++---
 libyelp/yelp-settings.c       |    4 ++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libyelp/yelp-location-entry.c b/libyelp/yelp-location-entry.c
index 06e1995..897e8e2 100644
--- a/libyelp/yelp-location-entry.c
+++ b/libyelp/yelp-location-entry.c
@@ -932,13 +932,17 @@ entry_activate_cb (GtkEntry  *text_entry,
                    gpointer   user_data)
 {
     YelpLocationEntryPrivate *priv = GET_PRIV (user_data);
-    gchar *text = g_strdup (gtk_entry_get_text (text_entry));
+    gchar *text;
 
     if (!priv->enable_search)
         return;
 
-    if (!priv->search_mode || text == NULL || strlen(text) == 0)
+    text = g_strdup (gtk_entry_get_text (text_entry));
+
+    if (!priv->search_mode || text == NULL || strlen(text) == 0) {
+        g_free (text);
         return;
+    }
 
     g_signal_emit (user_data, location_entry_signals[SEARCH_ACTIVATED], 0, text);
 
@@ -1430,7 +1434,7 @@ bookmarks_changed (YelpBookmarks      *bookmarks,
                    const gchar        *doc_uri,
                    YelpLocationEntry  *entry)
 {
-    GtkTreePath *path;
+    GtkTreePath *path = NULL;
     YelpLocationEntryPrivate *priv = GET_PRIV (entry);
 
     if (priv->row)
diff --git a/libyelp/yelp-settings.c b/libyelp/yelp-settings.c
index 20a8faa..532bca1 100644
--- a/libyelp/yelp-settings.c
+++ b/libyelp/yelp-settings.c
@@ -523,6 +523,8 @@ yelp_settings_get_font_family (YelpSettings     *settings,
 
  done:
     g_mutex_unlock (settings->priv->mutex);
+    g_free (desc);
+
     return ret;
 }
 
@@ -559,6 +561,8 @@ yelp_settings_get_font_size (YelpSettings     *settings,
     g_mutex_unlock (settings->priv->mutex);
     ret += settings->priv->font_adjustment;
     ret = (ret < 5) ? 5 : ret;
+    g_free (desc);
+
     return ret;
 }
 
-- 
1.7.2.3



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