summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-09-26 13:57:31 +0200
committerChristian Grothoff <christian@grothoff.org>2019-09-26 13:57:31 +0200
commit9f6bf3e0cfbd9cf974f614dac58218c10d33c9c2 (patch)
treee66afbcdc8b5ec586211e9b9dc3c137b330a9199
parent63994abe1e2780d3a43e261090d3261e8d91a854 (diff)
downloadmerchant-9f6bf3e0cfbd9cf974f614dac58218c10d33c9c2.tar.gz
merchant-9f6bf3e0cfbd9cf974f614dac58218c10d33c9c2.tar.bz2
merchant-9f6bf3e0cfbd9cf974f614dac58218c10d33c9c2.zip
fix memory leak
-rw-r--r--src/backend/taler-merchant-httpd.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
index 0accbb85..8e4db769 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -298,16 +298,13 @@ url_handler (void *cls,
&TMH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND
};
- struct TM_HandlerContext *hc;
+ struct TM_HandlerContext *hc = *con_cls;
struct GNUNET_AsyncScopeId aid;
const char *correlation_id = NULL;
char *instance_id;
- char *effective_url;
+ const char *effective_url;
int ret;
-
- hc = *con_cls;
-
if (NULL == hc)
{
GNUNET_async_scope_fresh (&aid);
@@ -347,14 +344,17 @@ url_handler (void *cls,
* from the beginning of the request URL. */
{
const char *instance_prefix = "/instances/";
- if (0 == strncmp (url, instance_prefix, strlen (instance_prefix)))
+
+ if (0 == strncmp (url,
+ instance_prefix,
+ strlen (instance_prefix)))
{
- // url starts with "/instance/"
- instance_id = GNUNET_strdup (url + strlen (instance_prefix));
- char *slash = strchr (instance_id, '/');
+ /* url starts with "/instances/" */
+ const char *istart = url + strlen (instance_prefix);
+ const char *slash = strchr (istart, '/');
+
if (NULL == slash)
{
- GNUNET_free (instance_id);
return TMH_MHD_handler_static_response (&h404,
connection,
con_cls,
@@ -362,18 +362,18 @@ url_handler (void *cls,
upload_data_size,
NULL);
}
- effective_url = GNUNET_strdup (slash);
- *slash = '\0';
+ instance_id = GNUNET_strndup (istart,
+ slash - istart);
+ effective_url = slash;
}
else
{
- effective_url = GNUNET_strdup (url);
+ effective_url = url;
instance_id = NULL;
}
}
-
- for (unsigned int i=0;NULL != handlers[i].url;i++)
+ for (unsigned int i = 0; NULL != handlers[i].url; i++)
{
struct TMH_RequestHandler *rh = &handlers[i];
@@ -384,10 +384,10 @@ url_handler (void *cls,
rh->method)) ) )
{
ret = rh->handler (rh,
- connection,
- con_cls,
- upload_data,
- upload_data_size,
+ connection,
+ con_cls,
+ upload_data,
+ upload_data_size,
instance_id);
hc = *con_cls;
if (NULL != hc)