fix memory leaks

This commit is contained in:
Christian Grothoff 2016-06-11 16:59:03 +02:00
parent 63612f4976
commit 6fb30ce468
4 changed files with 15 additions and 6 deletions

View File

@ -1563,14 +1563,14 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshRevealHandle *rrh,
{ {
unsigned int i; unsigned int i;
json_t *jsona; json_t *jsona;
struct GNUNET_JSON_Specification spec[] = { struct GNUNET_JSON_Specification outer_spec[] = {
GNUNET_JSON_spec_json ("ev_sigs", &jsona), GNUNET_JSON_spec_json ("ev_sigs", &jsona),
GNUNET_JSON_spec_end() GNUNET_JSON_spec_end()
}; };
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_JSON_parse (json, GNUNET_JSON_parse (json,
spec, outer_spec,
NULL, NULL)) NULL, NULL))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
@ -1580,12 +1580,14 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshRevealHandle *rrh,
{ {
/* We expected an array of coins */ /* We expected an array of coins */
GNUNET_break_op (0); GNUNET_break_op (0);
GNUNET_JSON_parse_free (outer_spec);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (rrh->md->num_fresh_coins != json_array_size (jsona)) if (rrh->md->num_fresh_coins != json_array_size (jsona))
{ {
/* Number of coins generated does not match our expectation */ /* Number of coins generated does not match our expectation */
GNUNET_break_op (0); GNUNET_break_op (0);
GNUNET_JSON_parse_free (outer_spec);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
for (i=0;i<rrh->md->num_fresh_coins;i++) for (i=0;i<rrh->md->num_fresh_coins;i++)
@ -1597,7 +1599,6 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshRevealHandle *rrh,
struct GNUNET_CRYPTO_RsaSignature *sig; struct GNUNET_CRYPTO_RsaSignature *sig;
struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_CoinSpendPublicKeyP coin_pub;
struct GNUNET_HashCode coin_hash; struct GNUNET_HashCode coin_hash;
struct GNUNET_JSON_Specification spec[] = { struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_rsa_signature ("ev_sig", &blind_sig), GNUNET_JSON_spec_rsa_signature ("ev_sig", &blind_sig),
GNUNET_JSON_spec_end() GNUNET_JSON_spec_end()
@ -1614,6 +1615,7 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshRevealHandle *rrh,
NULL, NULL)) NULL, NULL))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
GNUNET_JSON_parse_free (outer_spec);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
@ -1637,11 +1639,13 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshRevealHandle *rrh,
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
GNUNET_CRYPTO_rsa_signature_free (sig); GNUNET_CRYPTO_rsa_signature_free (sig);
GNUNET_JSON_parse_free (outer_spec);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
coin_privs[i] = fc->coin_priv; coin_privs[i] = fc->coin_priv;
sigs[i].rsa_signature = sig; sigs[i].rsa_signature = sig;
} }
GNUNET_JSON_parse_free (outer_spec);
return GNUNET_OK; return GNUNET_OK;
} }

View File

@ -138,6 +138,7 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
GNUNET_CRYPTO_hash_context_abort (hash_context); GNUNET_CRYPTO_hash_context_abort (hash_context);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
/* build up big hash for signature checking later */ /* build up big hash for signature checking later */
@ -166,6 +167,7 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh
&exchange_pub)) &exchange_pub))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (GNUNET_OK != if (GNUNET_OK !=
@ -173,6 +175,7 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh
&exchange_pub)) &exchange_pub))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
wdh->cb (wdh->cb_cls, wdh->cb (wdh->cb_cls,
@ -184,6 +187,7 @@ check_track_transfer_response_ok (struct TALER_EXCHANGE_TrackTransferHandle *wdh
num_details, num_details,
details); details);
} }
GNUNET_JSON_parse_free (spec);
TALER_EXCHANGE_track_transfer_cancel (wdh); TALER_EXCHANGE_track_transfer_cancel (wdh);
return GNUNET_OK; return GNUNET_OK;
} }

View File

@ -1915,6 +1915,7 @@ interpreter_run (void *cls)
} }
TALER_JSON_hash (contract, TALER_JSON_hash (contract,
&h_contract); &h_contract);
json_decref (contract);
wire = json_loads (cmd->details.deposit.wire_details, wire = json_loads (cmd->details.deposit.wire_details,
JSON_REJECT_DUPLICATES, JSON_REJECT_DUPLICATES,
NULL); NULL);