[libsoup] soup-server: fix a leak in server handlers
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] soup-server: fix a leak in server handlers
- Date: Sun, 1 Mar 2015 15:38:26 +0000 (UTC)
commit 37c8e71c0e4a080207575b9a16a632fe6e6071b0
Author: Dan Winship <danw gnome org>
Date: Sun Dec 7 12:35:35 2014 +0100
soup-server: fix a leak in server handlers
If a SoupServer handler specified a GDestroyNotify, it would only get
run when explicitly removing the handler, not when freeing the server.
Fix.
libsoup/soup-server.c | 23 ++++-------------------
1 files changed, 4 insertions(+), 19 deletions(-)
---
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index bd36e9b..a984aec 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -165,6 +165,8 @@ static void
free_handler (SoupServerHandler *hand)
{
g_free (hand->path);
+ if (hand->destroy)
+ hand->destroy (hand->user_data);
g_slice_free (SoupServerHandler, hand);
}
@@ -2363,13 +2365,6 @@ soup_server_add_handler (SoupServer *server,
priv->default_handler = hand;
}
-static void
-unregister_handler (SoupServerHandler *handler)
-{
- if (handler->destroy)
- handler->destroy (handler->user_data);
-}
-
/**
* soup_server_remove_handler:
* @server: a #SoupServer
@@ -2381,25 +2376,15 @@ void
soup_server_remove_handler (SoupServer *server, const char *path)
{
SoupServerPrivate *priv;
- SoupServerHandler *hand;
g_return_if_fail (SOUP_IS_SERVER (server));
priv = SOUP_SERVER_GET_PRIVATE (server);
if (!path || !*path || !strcmp (path, "/")) {
- if (priv->default_handler) {
- unregister_handler (priv->default_handler);
- free_handler (priv->default_handler);
- priv->default_handler = NULL;
- }
+ g_clear_pointer (&priv->default_handler, free_handler);
return;
- }
-
- hand = soup_path_map_lookup (priv->handlers, path);
- if (hand && !strcmp (path, hand->path)) {
- unregister_handler (hand);
+ } else
soup_path_map_remove (priv->handlers, path);
- }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]