diff --git a/crypto/dsa/dsa_asn1.c b/crypto/dsa/dsa_asn1.c index 7615fca2..ff5ee003 100644 --- a/crypto/dsa/dsa_asn1.c +++ b/crypto/dsa/dsa_asn1.c @@ -248,6 +248,7 @@ int i2d_DSA_SIG(const DSA_SIG *in, uint8_t **outp) { CBB cbb; if (!CBB_init(&cbb, 0) || !DSA_SIG_marshal(&cbb, in)) { + CBB_cleanup(&cbb); return -1; } return CBB_finish_i2d(&cbb, outp); @@ -275,6 +276,7 @@ int i2d_DSAPublicKey(const DSA *in, uint8_t **outp) { CBB cbb; if (!CBB_init(&cbb, 0) || !DSA_marshal_public_key(&cbb, in)) { + CBB_cleanup(&cbb); return -1; } return CBB_finish_i2d(&cbb, outp); @@ -302,6 +304,7 @@ int i2d_DSAPrivateKey(const DSA *in, uint8_t **outp) { CBB cbb; if (!CBB_init(&cbb, 0) || !DSA_marshal_private_key(&cbb, in)) { + CBB_cleanup(&cbb); return -1; } return CBB_finish_i2d(&cbb, outp); @@ -329,6 +332,7 @@ int i2d_DSAparams(const DSA *in, uint8_t **outp) { CBB cbb; if (!CBB_init(&cbb, 0) || !DSA_marshal_parameters(&cbb, in)) { + CBB_cleanup(&cbb); return -1; } return CBB_finish_i2d(&cbb, outp); diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index a29a2dcf..0535a79f 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c @@ -401,6 +401,7 @@ int i2d_ECPrivateKey(const EC_KEY *key, uint8_t **outp) { CBB cbb; if (!CBB_init(&cbb, 0) || !EC_KEY_marshal_private_key(&cbb, key, EC_KEY_get_enc_flags(key))) { + CBB_cleanup(&cbb); return -1; } return CBB_finish_i2d(&cbb, outp); @@ -449,6 +450,7 @@ int i2d_ECParameters(const EC_KEY *key, uint8_t **outp) { CBB cbb; if (!CBB_init(&cbb, 0) || !OBJ_nid2cbb(&cbb, curve_nid)) { + CBB_cleanup(&cbb); return -1; } return CBB_finish_i2d(&cbb, outp); diff --git a/crypto/ecdsa/ecdsa_asn1.c b/crypto/ecdsa/ecdsa_asn1.c index 3a47257a..d41a5366 100644 --- a/crypto/ecdsa/ecdsa_asn1.c +++ b/crypto/ecdsa/ecdsa_asn1.c @@ -220,6 +220,7 @@ int i2d_ECDSA_SIG(const ECDSA_SIG *sig, uint8_t **outp) { CBB cbb; if (!CBB_init(&cbb, 0) || !ECDSA_SIG_marshal(&cbb, sig)) { + CBB_cleanup(&cbb); return -1; } return CBB_finish_i2d(&cbb, outp);