Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-02-27 00:22:21 +0300
committerAdam Langley <agl@google.com>2015-02-27 22:45:42 +0300
commit29b50eab6c709a4c84e245e259f9ff4c4c2b8d00 (patch)
tree4cf345091b800e56e1d798aeeff0c81cbb68fcc3 /crypto
parent114ddebbf62601aaf6ed09bf87aec8b72402afcb (diff)
Align d2i_ECPrivateKey error-handling with upstream.
Upstream decided to make the caller free the scratch space rather than the callee. May as well match. (Existing code is pretty inconsistent. This API pattern needs to go.) See upstream's 9e442d485008046933cdc7da65080f436a4af089. Change-Id: I7c9fcae5778a74d6ae8e9f546e03fb2cf6e48426 Reviewed-on: https://boringssl-review.googlesource.com/3671 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/ec/ec_asn1.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c
index ce9b3f40..5b3e048f 100644
--- a/crypto/ec/ec_asn1.c
+++ b/crypto/ec/ec_asn1.c
@@ -309,9 +309,6 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const uint8_t **in, long len) {
OPENSSL_PUT_ERROR(EC, d2i_ECPrivateKey, ERR_R_MALLOC_FAILURE);
goto err;
}
- if (a) {
- *a = ret;
- }
} else {
ret = *a;
}
@@ -380,17 +377,17 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const uint8_t **in, long len) {
ret->enc_flag |= EC_PKEY_NO_PUBKEY;
}
+ if (a) {
+ *a = ret;
+ }
ok = 1;
err:
if (!ok) {
- if (ret) {
+ if (ret && (a == NULL || *a != ret)) {
EC_KEY_free(ret);
}
ret = NULL;
- if (a) {
- *a = ret;
- }
}
if (priv_key) {