diff options
author | Jan-Michael Brummer <jan.brummer@tabos.org> | 2020-06-25 11:41:15 +0200 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@gnome.org> | 2020-06-25 15:59:06 +0000 |
commit | ca300c9f439bef880797856a16bab5f8c4637120 (patch) | |
tree | 487723527cf954627517ea9283d4da0dcc38fb15 /lib | |
parent | 5a75e6663d756d0e0f9e37f3067ba866510c5a3f (diff) | |
download | epiphany-ca300c9f439bef880797856a16bab5f8c4637120.tar.gz |
Fix memory leaks in history query results
Fixes: https://gitlab.gnome.org/GNOME/epiphany/-/issues/1178
Diffstat (limited to 'lib')
-rw-r--r-- | lib/history/ephy-history-service.c | 41 | ||||
-rw-r--r-- | lib/history/ephy-history-types.c | 6 | ||||
-rw-r--r-- | lib/history/ephy-history-types.h | 1 | ||||
-rw-r--r-- | lib/sync/ephy-history-manager.c | 1 |
4 files changed, 35 insertions, 14 deletions
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c index 9c869825d..e9660f8e2 100644 --- a/lib/history/ephy-history-service.c +++ b/lib/history/ephy-history-service.c @@ -79,6 +79,7 @@ typedef struct _EphyHistoryServiceMessage { gpointer user_data; GCancellable *cancellable; GDestroyNotify method_argument_cleanup; + GDestroyNotify result_cleanup; EphyHistoryJobCallback callback; } EphyHistoryServiceMessage; @@ -335,6 +336,7 @@ ephy_history_service_message_new (EphyHistoryService *service, EphyHistoryServiceMessageType type, gpointer method_argument, GDestroyNotify method_argument_cleanup, + GDestroyNotify result_cleanup, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data) @@ -345,6 +347,7 @@ ephy_history_service_message_new (EphyHistoryService *service, message->type = type; message->method_argument = method_argument; message->method_argument_cleanup = method_argument_cleanup; + message->result_cleanup = result_cleanup; message->cancellable = cancellable ? g_object_ref (cancellable) : NULL; message->callback = callback; message->user_data = user_data; @@ -358,6 +361,9 @@ ephy_history_service_message_free (EphyHistoryServiceMessage *message) if (message->method_argument_cleanup) message->method_argument_cleanup (message->method_argument); + if (message->result_cleanup) + message->result_cleanup (message->result); + if (message->cancellable) g_object_unref (message->cancellable); @@ -698,6 +704,7 @@ ephy_history_service_add_visit (EphyHistoryService *self, message = ephy_history_service_message_new (self, ADD_VISIT, ephy_history_page_visit_copy (visit), (GDestroyNotify)ephy_history_page_visit_free, + NULL, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -717,6 +724,7 @@ ephy_history_service_add_visits (EphyHistoryService *self, message = ephy_history_service_message_new (self, ADD_VISITS, ephy_history_page_visit_list_copy (visits), (GDestroyNotify)ephy_history_page_visit_list_free, + NULL, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -754,7 +762,10 @@ ephy_history_service_query_visits (EphyHistoryService *self, g_assert (query != NULL); message = ephy_history_service_message_new (self, QUERY_VISITS, - ephy_history_query_copy (query), (GDestroyNotify)ephy_history_query_free, cancellable, callback, user_data); + ephy_history_query_copy (query), + (GDestroyNotify)ephy_history_query_free, + (GDestroyNotify)ephy_history_page_visit_list_free, + cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -783,7 +794,9 @@ ephy_history_service_query_urls (EphyHistoryService *self, g_assert (query != NULL); message = ephy_history_service_message_new (self, QUERY_URLS, - ephy_history_query_copy (query), (GDestroyNotify)ephy_history_query_free, + ephy_history_query_copy (query), + (GDestroyNotify)ephy_history_query_free, + (GDestroyNotify)ephy_history_url_list_free, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -799,8 +812,9 @@ ephy_history_service_get_hosts (EphyHistoryService *self, g_assert (EPHY_IS_HISTORY_SERVICE (self)); message = ephy_history_service_message_new (self, GET_HOSTS, - NULL, NULL, cancellable, - callback, user_data); + NULL, NULL, + (GDestroyNotify)ephy_history_host_list_free, + cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -818,6 +832,7 @@ ephy_history_service_query_hosts (EphyHistoryService *self, message = ephy_history_service_message_new (self, QUERY_HOSTS, ephy_history_query_copy (query), (GDestroyNotify)ephy_history_query_free, + (GDestroyNotify)ephy_history_host_list_free, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -879,7 +894,7 @@ ephy_history_service_set_url_title (EphyHistoryService *self, url = ephy_history_url_new (orig_url, title, 0, 0, 0); message = ephy_history_service_message_new (self, SET_URL_TITLE, url, (GDestroyNotify)ephy_history_url_free, - cancellable, callback, user_data); + NULL, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -927,7 +942,7 @@ ephy_history_service_set_url_zoom_level (EphyHistoryService *self, message = ephy_history_service_message_new (self, SET_URL_ZOOM_LEVEL, variant, (GDestroyNotify)g_variant_unref, - cancellable, callback, user_data); + NULL, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -969,7 +984,7 @@ ephy_history_service_set_url_hidden (EphyHistoryService *self, message = ephy_history_service_message_new (self, SET_URL_HIDDEN, url, (GDestroyNotify)ephy_history_url_free, - cancellable, callback, user_data); + NULL, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -1000,7 +1015,7 @@ ephy_history_service_get_url (EphyHistoryService *self, g_assert (url != NULL); message = ephy_history_service_message_new (self, GET_URL, - g_strdup (url), g_free, + g_strdup (url), g_free, (GDestroyNotify)ephy_history_url_free, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -1033,7 +1048,7 @@ ephy_history_service_get_host_for_url (EphyHistoryService *self, g_assert (url != NULL); message = ephy_history_service_message_new (self, GET_HOST_FOR_URL, - g_strdup (url), g_free, + g_strdup (url), g_free, (GDestroyNotify)ephy_history_host_free, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -1138,7 +1153,7 @@ ephy_history_service_delete_urls (EphyHistoryService *self, message = ephy_history_service_message_new (self, DELETE_URLS, ephy_history_url_list_copy (urls), (GDestroyNotify)ephy_history_url_list_free, - cancellable, callback, user_data); + NULL, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -1152,7 +1167,7 @@ ephy_history_service_delete_host (EphyHistoryService *self, EphyHistoryServiceMessage *message = ephy_history_service_message_new (self, DELETE_HOST, ephy_history_host_copy (host), (GDestroyNotify)ephy_history_host_free, - cancellable, callback, user_data); + NULL, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -1167,7 +1182,7 @@ ephy_history_service_clear (EphyHistoryService *self, g_assert (EPHY_IS_HISTORY_SERVICE (self)); message = ephy_history_service_message_new (self, CLEAR, - NULL, NULL, + NULL, NULL, NULL, cancellable, callback, user_data); ephy_history_service_send_message (self, message); } @@ -1179,7 +1194,7 @@ ephy_history_service_quit (EphyHistoryService *self, { EphyHistoryServiceMessage *message = ephy_history_service_message_new (self, QUIT, - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, callback, user_data); ephy_history_service_send_message (self, message); } diff --git a/lib/history/ephy-history-types.c b/lib/history/ephy-history-types.c index 9a806f7fd..b1b4b5ba2 100644 --- a/lib/history/ephy-history-types.c +++ b/lib/history/ephy-history-types.c @@ -126,6 +126,12 @@ ephy_history_host_free (EphyHistoryHost *host) g_free (host); } +void +ephy_history_host_list_free (GList *list) +{ + g_list_free_full (list, (GDestroyNotify)ephy_history_host_free); +} + EphyHistoryURL * ephy_history_url_new (const char *url, const char *title, diff --git a/lib/history/ephy-history-types.h b/lib/history/ephy-history-types.h index 692ab50c9..20dacfbdf 100644 --- a/lib/history/ephy-history-types.h +++ b/lib/history/ephy-history-types.h @@ -105,6 +105,7 @@ void ephy_history_page_visit_list_free (GList* list); EphyHistoryHost * ephy_history_host_new (const char *url, const char *title, int visit_count, double zoom_level); EphyHistoryHost * ephy_history_host_copy (EphyHistoryHost *original); void ephy_history_host_free (EphyHistoryHost *host); +void ephy_history_host_list_free (GList *list); EphyHistoryURL * ephy_history_url_new (const char *url, const char *title, int visit_count, int typed_count, gint64 last_visit_time); EphyHistoryURL * ephy_history_url_copy (EphyHistoryURL *url); diff --git a/lib/sync/ephy-history-manager.c b/lib/sync/ephy-history-manager.c index df94e2034..bffcd1ca3 100644 --- a/lib/sync/ephy-history-manager.c +++ b/lib/sync/ephy-history-manager.c @@ -513,7 +513,6 @@ merge_history_cb (EphyHistoryService *service, out: data->callback (to_upload, data->user_data); - g_list_free_full (urls, (GDestroyNotify)ephy_history_url_free); if (records_ht_id) g_hash_table_unref (records_ht_id); if (records_ht_url) |