attr = NULL;
rval = ber_decode(NULL, td, &attr, ber->buf, ber->size);
- if (rval.code != RC_OK)
- return NULL; /* TODO release attr? */
- json = td->op->json_encoder(td, attr);
+ json = (rval.code == RC_OK) ? td->op->json_encoder(td, attr) : NULL;
ASN_STRUCT_FREE(*td, attr);
return json;
{
void *decoded;
asn_dec_rval_t rval;
- json_t *content;
+ json_t *json;
decoded = NULL;
rval = ber_decode(NULL, td, &decoded, ber->buf, ber->size);
- if (rval.code != RC_OK)
- return NULL;
- content = td->op->json_encoder(td, decoded);
+ json = (rval.code == RC_OK) ? td->op->json_encoder(td, decoded) : NULL;
ASN_STRUCT_FREE(*td, decoded);
- return content;
+ return json;
}
json_t *
{
void *decoded;
asn_dec_rval_t rval;
- json_t *content;
+ json_t *json;
decoded = NULL;
rval = ber_decode(NULL, td, &decoded, eContent->buf, eContent->size);
- if (rval.code != RC_OK)
- return NULL;
- content = td->op->json_encoder(td, decoded);
+ json = (rval.code == RC_OK) ? td->op->json_encoder(td, decoded) : NULL;
ASN_STRUCT_FREE(*td, decoded);
- return content;
+ return json;
}
json_t *
do {
if (!BIO_read_ex(bio, buffer, BUFFER_SIZE, &consumed)) {
op_crypto_err("IO error.");
- return NULL;
+ goto fail;
}
res = ber_decode(NULL, &asn_DEF_ContentInfo, (void **)&ci,
case RC_FAIL:
pr_op_err("Unsuccessful parse.");
- return NULL;
+ goto fail;
}
} while (true);
+
+fail: ASN_STRUCT_FREE(asn_DEF_ContentInfo, ci);
+ return NULL;
}
static json_t *