diff options
author | David Benjamin <davidben@chromium.org> | 2015-04-22 22:08:19 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-05-05 02:08:22 +0300 |
commit | cfaf7ff9bf877239f17c805af6a3d7daae48e0a2 (patch) | |
tree | 873c4b8f54c1ba44b94e0c4ff13fd0d4ab516e5d /crypto/ec/ec_asn1.c | |
parent | 22ccc2d8f1e0a3d19b98324d502322db8d89624f (diff) |
Remove unnecessary NULL checks, part 2.
Stuff in crypto/ec.
Change-Id: I3bd238c365c4766ed8abc6f835a107478b43b159
Reviewed-on: https://boringssl-review.googlesource.com/4515
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/ec/ec_asn1.c')
-rw-r--r-- | crypto/ec/ec_asn1.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index c32ae131..ff3dca6d 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c @@ -172,9 +172,7 @@ ECPKPARAMETERS *ec_asn1_group2pkparameters(const EC_GROUP *group, return NULL; } } else { - if (ret->value.named_curve) { - ASN1_OBJECT_free(ret->value.named_curve); - } + ASN1_OBJECT_free(ret->value.named_curve); } /* use the ASN.1 OID to describe the the elliptic curve parameters. */ @@ -257,10 +255,8 @@ static EC_GROUP *d2i_ECPKParameters(EC_GROUP **groupp, const uint8_t **inp, return NULL; } - if (groupp && *groupp) { - EC_GROUP_free(*groupp); - } if (groupp) { + EC_GROUP_free(*groupp); *groupp = group; } @@ -307,9 +303,7 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const uint8_t **in, long len) { } if (priv_key->parameters) { - if (ret->group) { - EC_GROUP_free(ret->group); - } + EC_GROUP_free(ret->group); ret->group = ec_asn1_pkparameters2group(priv_key->parameters); } @@ -333,9 +327,7 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const uint8_t **in, long len) { goto err; } - if (ret->pub_key) { - EC_POINT_free(ret->pub_key); - } + EC_POINT_free(ret->pub_key); ret->pub_key = EC_POINT_new(ret->group); if (ret->pub_key == NULL) { OPENSSL_PUT_ERROR(EC, d2i_ECPrivateKey, ERR_R_EC_LIB); @@ -377,15 +369,13 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const uint8_t **in, long len) { err: if (!ok) { - if (ret && (a == NULL || *a != ret)) { + if (a == NULL || *a != ret) { EC_KEY_free(ret); } ret = NULL; } - if (priv_key) { - EC_PRIVATEKEY_free(priv_key); - } + EC_PRIVATEKEY_free(priv_key); return ret; } @@ -478,12 +468,8 @@ int i2d_ECPrivateKey(const EC_KEY *key, uint8_t **outp) { ok = 1; err: - if (buffer) { - OPENSSL_free(buffer); - } - if (priv_key) { - EC_PRIVATEKEY_free(priv_key); - } + OPENSSL_free(buffer); + EC_PRIVATEKEY_free(priv_key); return (ok ? ret : 0); } |