diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-06-04 13:26:00 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-06-04 13:26:00 +0200 |
commit | 809300158caaa0215c36ef89c7e38f0edfa93593 (patch) | |
tree | 1faf7e314af34db7a2333d8003ee0ed6fca91d74 /src/exchange-tools | |
parent | 9718bc4920ab4781378b777bf3e2af275c8d0575 (diff) |
code cleanup, fixing misc. memory leaks in the process
Diffstat (limited to 'src/exchange-tools')
-rw-r--r-- | src/exchange-tools/taler-auditor-offline.c | 16 | ||||
-rw-r--r-- | src/exchange-tools/taler-exchange-offline.c | 78 |
2 files changed, 38 insertions, 56 deletions
diff --git a/src/exchange-tools/taler-auditor-offline.c b/src/exchange-tools/taler-auditor-offline.c index f239c11a9..cd439d231 100644 --- a/src/exchange-tools/taler-auditor-offline.c +++ b/src/exchange-tools/taler-auditor-offline.c @@ -949,11 +949,11 @@ do_show (char *const *args) json_t *keys; const char *err_name; unsigned int err_line; - json_t *denomkeys; + const json_t *denomkeys; struct TALER_MasterPublicKeyP mpub; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("denoms", - &denomkeys), + GNUNET_JSON_spec_array_const ("denoms", + &denomkeys), GNUNET_JSON_spec_fixed_auto ("master_public_key", &mpub), GNUNET_JSON_spec_end () @@ -997,11 +997,9 @@ do_show (char *const *args) { global_ret = EXIT_FAILURE; test_shutdown (); - GNUNET_JSON_parse_free (spec); json_decref (keys); return; } - GNUNET_JSON_parse_free (spec); json_decref (keys); /* do NOT consume input if next argument is '-' */ if ( (NULL != args[0]) && @@ -1138,10 +1136,10 @@ do_sign (char *const *args) const char *err_name; unsigned int err_line; struct TALER_MasterPublicKeyP mpub; - json_t *denomkeys; + const json_t *denomkeys; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("denoms", - &denomkeys), + GNUNET_JSON_spec_array_const ("denoms", + &denomkeys), GNUNET_JSON_spec_fixed_auto ("master_public_key", &mpub), GNUNET_JSON_spec_end () @@ -1196,11 +1194,9 @@ do_sign (char *const *args) { global_ret = EXIT_FAILURE; test_shutdown (); - GNUNET_JSON_parse_free (spec); json_decref (keys); return; } - GNUNET_JSON_parse_free (spec); json_decref (keys); next (args); } diff --git a/src/exchange-tools/taler-exchange-offline.c b/src/exchange-tools/taler-exchange-offline.c index b1aababc4..77c163c3e 100644 --- a/src/exchange-tools/taler-exchange-offline.c +++ b/src/exchange-tools/taler-exchange-offline.c @@ -1539,8 +1539,8 @@ upload_wire_add (const char *exchange_url, struct WireAddRequest *war; const char *err_name; const char *conversion_url = NULL; - json_t *debit_restrictions; - json_t *credit_restrictions; + const json_t *debit_restrictions; + const json_t *credit_restrictions; unsigned int err_line; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("payto_uri", @@ -1549,10 +1549,10 @@ upload_wire_add (const char *exchange_url, GNUNET_JSON_spec_string ("conversion_url", &conversion_url), NULL), - GNUNET_JSON_spec_json ("debit_restrictions", - &debit_restrictions), - GNUNET_JSON_spec_json ("credit_restrictions", - &credit_restrictions), + GNUNET_JSON_spec_array_const ("debit_restrictions", + &debit_restrictions), + GNUNET_JSON_spec_array_const ("credit_restrictions", + &credit_restrictions), GNUNET_JSON_spec_timestamp ("validity_start", &start_time), GNUNET_JSON_spec_fixed_auto ("master_sig_add", @@ -1577,7 +1577,6 @@ upload_wire_add (const char *exchange_url, stderr, JSON_INDENT (2)); global_ret = EXIT_FAILURE; - GNUNET_JSON_parse_free (spec); test_shutdown (); return; } @@ -1591,7 +1590,6 @@ upload_wire_add (const char *exchange_url, "payto:// URI `%s' is malformed\n", payto_uri); global_ret = EXIT_FAILURE; - GNUNET_JSON_parse_free (spec); test_shutdown (); return; } @@ -1606,7 +1604,6 @@ upload_wire_add (const char *exchange_url, "payto URI is malformed: %s\n", msg); GNUNET_free (msg); - GNUNET_JSON_parse_free (spec); test_shutdown (); global_ret = EXIT_INVALIDARGUMENT; return; @@ -1629,7 +1626,6 @@ upload_wire_add (const char *exchange_url, GNUNET_CONTAINER_DLL_insert (war_head, war_tail, war); - GNUNET_JSON_parse_free (spec); } @@ -2102,13 +2098,13 @@ upload_keys (const char *exchange_url, struct UploadKeysRequest *ukr; const char *err_name; unsigned int err_line; - json_t *denom_sigs; - json_t *signkey_sigs; + const json_t *denom_sigs; + const json_t *signkey_sigs; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("denom_sigs", - &denom_sigs), - GNUNET_JSON_spec_json ("signkey_sigs", - &signkey_sigs), + GNUNET_JSON_spec_array_const ("denom_sigs", + &denom_sigs), + GNUNET_JSON_spec_array_const ("signkey_sigs", + &signkey_sigs), GNUNET_JSON_spec_end () }; bool ok = true; @@ -2224,7 +2220,6 @@ upload_keys (const char *exchange_url, } GNUNET_free (pkd.sign_sigs); GNUNET_free (pkd.denom_sigs); - GNUNET_JSON_parse_free (spec); } @@ -2272,13 +2267,13 @@ upload_extensions (const char *exchange_url, size_t idx, const json_t *value) { - json_t *extensions; + const json_t *extensions; struct TALER_MasterSignatureP sig; const char *err_name; unsigned int err_line; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("extensions", - &extensions), + GNUNET_JSON_spec_object_const ("extensions", + &extensions), GNUNET_JSON_spec_fixed_auto ("extensions_sig", &sig), GNUNET_JSON_spec_end () @@ -2309,9 +2304,9 @@ upload_extensions (const char *exchange_url, struct TALER_ExtensionManifestsHashP h_manifests; if (GNUNET_OK != - TALER_JSON_extensions_manifests_hash (extensions, &h_manifests)) + TALER_JSON_extensions_manifests_hash (extensions, + &h_manifests)) { - GNUNET_JSON_parse_free (spec); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "couldn't hash extensions' manifests\n"); global_ret = EXIT_FAILURE; @@ -2328,7 +2323,6 @@ upload_extensions (const char *exchange_url, &master_pub, &sig)) { - GNUNET_JSON_parse_free (spec); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "invalid signature for extensions\n"); global_ret = EXIT_FAILURE; @@ -2343,8 +2337,9 @@ upload_extensions (const char *exchange_url, .extensions = extensions, .extensions_sig = sig, }; - struct UploadExtensionsRequest *uer = GNUNET_new (struct - UploadExtensionsRequest); + struct UploadExtensionsRequest *uer + = GNUNET_new (struct UploadExtensionsRequest); + uer->idx = idx; uer->h = TALER_EXCHANGE_management_post_extensions ( ctx, @@ -2356,7 +2351,6 @@ upload_extensions (const char *exchange_url, uer_tail, uer); } - GNUNET_JSON_parse_free (spec); } @@ -4482,15 +4476,15 @@ do_show (char *const *args) json_t *keys; const char *err_name; unsigned int err_line; - json_t *denomkeys; - json_t *signkeys; + const json_t *denomkeys; + const json_t *signkeys; struct TALER_MasterPublicKeyP mpub; struct TALER_SecurityModulePublicKeySetP secmset; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("future_denoms", - &denomkeys), - GNUNET_JSON_spec_json ("future_signkeys", - &signkeys), + GNUNET_JSON_spec_array_const ("future_denoms", + &denomkeys), + GNUNET_JSON_spec_array_const ("future_signkeys", + &signkeys), GNUNET_JSON_spec_fixed_auto ("master_pub", &mpub), GNUNET_JSON_spec_fixed_auto ("denom_secmod_public_key", @@ -4535,7 +4529,6 @@ do_show (char *const *args) "Fatal: exchange uses different master key!\n"); global_ret = EXIT_FAILURE; test_shutdown (); - GNUNET_JSON_parse_free (spec); json_decref (keys); return; } @@ -4544,7 +4537,6 @@ do_show (char *const *args) { global_ret = EXIT_FAILURE; test_shutdown (); - GNUNET_JSON_parse_free (spec); json_decref (keys); return; } @@ -4558,12 +4550,10 @@ do_show (char *const *args) { global_ret = EXIT_FAILURE; test_shutdown (); - GNUNET_JSON_parse_free (spec); json_decref (keys); return; } json_decref (keys); - GNUNET_JSON_parse_free (spec); next (args); } @@ -4883,15 +4873,15 @@ do_sign (char *const *args) json_t *keys; const char *err_name; unsigned int err_line; - json_t *denomkeys; - json_t *signkeys; + const json_t *denomkeys; + const json_t *signkeys; struct TALER_MasterPublicKeyP mpub; struct TALER_SecurityModulePublicKeySetP secmset; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("future_denoms", - &denomkeys), - GNUNET_JSON_spec_json ("future_signkeys", - &signkeys), + GNUNET_JSON_spec_array_const ("future_denoms", + &denomkeys), + GNUNET_JSON_spec_array_const ("future_signkeys", + &signkeys), GNUNET_JSON_spec_fixed_auto ("master_pub", &mpub), GNUNET_JSON_spec_fixed_auto ("denom_secmod_public_key", @@ -4938,7 +4928,6 @@ do_sign (char *const *args) "Fatal: exchange uses different master key!\n"); global_ret = EXIT_FAILURE; test_shutdown (); - GNUNET_JSON_parse_free (spec); json_decref (keys); return; } @@ -4949,7 +4938,6 @@ do_sign (char *const *args) "Fatal: security module keys changed!\n"); global_ret = EXIT_FAILURE; test_shutdown (); - GNUNET_JSON_parse_free (spec); json_decref (keys); return; } @@ -4973,7 +4961,6 @@ do_sign (char *const *args) test_shutdown (); json_decref (signkey_sig_array); json_decref (denomkey_sig_array); - GNUNET_JSON_parse_free (spec); json_decref (keys); return; } @@ -4985,7 +4972,6 @@ do_sign (char *const *args) GNUNET_JSON_pack_array_steal ("signkey_sigs", signkey_sig_array))); } - GNUNET_JSON_parse_free (spec); json_decref (keys); next (args); } |