diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-12-23 15:28:32 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-12-23 15:28:32 +0000 |
commit | f1262b46f67e6a99d12052da93e8157e0935783c (patch) | |
tree | 11fe0f4c6dfea9f57c110f856a90dd8919cc284d | |
parent | da36cc644b5cf2afa40b8e26c22edfe64acc3e40 (diff) | |
download | rspamd-f1262b46f67e6a99d12052da93e8157e0935783c.tar.gz rspamd-f1262b46f67e6a99d12052da93e8157e0935783c.zip |
[Minor] Fix lifetime
This is a reason why I hate C
-rw-r--r-- | src/libserver/http/http_router.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/libserver/http/http_router.c b/src/libserver/http/http_router.c index 9f36118b2..a5b960e72 100644 --- a/src/libserver/http/http_router.c +++ b/src/libserver/http/http_router.c @@ -254,6 +254,7 @@ rspamd_http_router_finish_handler (struct rspamd_http_connection *conn, guint i; rspamd_regexp_t *re; struct rspamd_http_connection_router *router; + gchar *pathbuf = NULL; G_STATIC_ASSERT (sizeof (rspamd_http_router_handler_t) == sizeof (gpointer)); @@ -286,7 +287,6 @@ rspamd_http_router_finish_handler (struct rspamd_http_connection *conn, /* Search for path */ if (msg->url != NULL && msg->url->len != 0) { - gchar *pathbuf = NULL; http_parser_parse_url (msg->url->str, msg->url->len, TRUE, &u); @@ -312,10 +312,6 @@ rspamd_http_router_finish_handler (struct rspamd_http_connection *conn, found = g_hash_table_lookup (entry->rt->paths, &lookup); memcpy (&handler, &found, sizeof (found)); msg_debug ("requested known path: %T", &lookup); - - if (pathbuf) { - g_free (pathbuf); - } } else { err = g_error_new (HTTP_ERROR, 404, @@ -340,6 +336,10 @@ rspamd_http_router_finish_handler (struct rspamd_http_connection *conn, } if (handler != NULL) { + if (pathbuf) { + g_free (pathbuf); + } + return handler (entry, msg); } else { @@ -351,6 +351,10 @@ rspamd_http_router_finish_handler (struct rspamd_http_connection *conn, found = rspamd_regexp_get_ud (re); memcpy (&handler, &found, sizeof (found)); + if (pathbuf) { + g_free (pathbuf); + } + return handler (entry, msg); } } @@ -372,6 +376,10 @@ rspamd_http_router_finish_handler (struct rspamd_http_connection *conn, } } + if (pathbuf) { + g_free (pathbuf); + } + return 0; } |