diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-27 14:35:59 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-27 14:36:04 +0200 |
commit | 5017dacbdaac2d1654b01329f97b8b5b7dc34ba9 (patch) | |
tree | d94ef5b2741ca6655b80a6433bca34ef119c21f4 /src | |
parent | 6761e2a997efbd76e412b6d6343aba3a14c9a703 (diff) |
-fix memory leak
Diffstat (limited to 'src')
-rw-r--r-- | src/include/taler_mhd_lib.h | 19 | ||||
-rw-r--r-- | src/mhd/mhd_responses.c | 15 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/include/taler_mhd_lib.h b/src/include/taler_mhd_lib.h index 3af413fa8..aba7cd8e2 100644 --- a/src/include/taler_mhd_lib.h +++ b/src/include/taler_mhd_lib.h @@ -125,6 +125,21 @@ TALER_MHD_reply_json (struct MHD_Connection *connection, /** + * Send JSON object as response, and free the @a json + * object. + * + * @param connection the MHD connection + * @param json the json object (freed!) + * @param response_code the http response code + * @return MHD result code + */ +MHD_RESULT +TALER_MHD_reply_json_steal (struct MHD_Connection *connection, + json_t *json, + unsigned int response_code); + + +/** * Function to call to handle the request by building a JSON * reply from a format string and varargs. * @@ -151,8 +166,8 @@ TALER_MHD_reply_json_pack (struct MHD_Connection *connection, * @return MHD result code */ #define TALER_MHD_REPLY_JSON_PACK(connection,response_code,...) \ - TALER_MHD_reply_json (connection, GNUNET_JSON_PACK (__VA_ARGS__), \ - response_code) + TALER_MHD_reply_json_steal (connection, GNUNET_JSON_PACK (__VA_ARGS__), \ + response_code) /** diff --git a/src/mhd/mhd_responses.c b/src/mhd/mhd_responses.c index 6b96de55d..b7ff52e66 100644 --- a/src/mhd/mhd_responses.c +++ b/src/mhd/mhd_responses.c @@ -220,6 +220,21 @@ TALER_MHD_reply_json (struct MHD_Connection *connection, MHD_RESULT +TALER_MHD_reply_json_steal (struct MHD_Connection *connection, + json_t *json, + unsigned int response_code) +{ + MHD_RESULT ret; + + ret = TALER_MHD_reply_json (connection, + json, + response_code); + json_decref (json); + return ret; +} + + +MHD_RESULT TALER_MHD_reply_cors_preflight (struct MHD_Connection *connection) { struct MHD_Response *response; |