check json_array_append_new() return values, proper logging on errors

This commit is contained in:
Christian Grothoff 2017-09-26 12:30:24 +02:00
parent a3b71ac75b
commit 7cb48a720b
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 100 additions and 91 deletions

View File

@ -516,8 +516,10 @@ decode_keys_json (const json_t *resp_obj,
unsigned int current;
if (JSON_OBJECT != json_typeof (resp_obj))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
/* check the version */
{
const char *ver;
@ -527,10 +529,14 @@ decode_keys_json (const json_t *resp_obj,
GNUNET_JSON_spec_end()
};
EXITIF (GNUNET_OK !=
GNUNET_JSON_parse (resp_obj,
spec,
NULL, NULL));
if (GNUNET_OK !=
GNUNET_JSON_parse (resp_obj,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
if (3 != sscanf (ver,
"%u:%u:%u",
&current,

View File

@ -1104,8 +1104,9 @@ add_auditor_entry (void *cls,
"denomination_keys", ae->ar,
"auditor_url", ae->auditor_url,
"auditor_pub", GNUNET_JSON_from_data_auto (ae->apub));
json_array_append_new (rbc->auditors_array,
ao);
GNUNET_assert (0 ==
json_array_append_new (rbc->auditors_array,
ao));
GNUNET_free (ae);
return GNUNET_OK;
}
@ -1211,12 +1212,13 @@ build_keys_response (const struct ResponseFactoryContext *rfc,
ae,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
}
json_array_append_new (ae->ar,
json_pack ("{s:o, s:o}",
"denom_pub_h",
GNUNET_JSON_from_data_auto (&denom_key_hash),
"auditor_sig",
GNUNET_JSON_from_data_auto (&as->asig)));
GNUNET_assert (0 ==
json_array_append_new (ae->ar,
json_pack ("{s:o, s:o}",
"denom_pub_h",
GNUNET_JSON_from_data_auto (&denom_key_hash),
"auditor_sig",
GNUNET_JSON_from_data_auto (&as->asig))));
}
}

View File

@ -2458,6 +2458,7 @@ postgres_get_reserve_history (void *cls,
rhc.rh = NULL;
rhc.rh_tail = NULL;
rhc.status = GNUNET_OK;
qs = GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; /* make static analysis happy */
for (unsigned int i=0;NULL != work[i].cb;i++)
{
qs = GNUNET_PQ_eval_prepared_multi_select (session->conn,