summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2016-04-27 20:27:41 +0100
committerDr. Stephen Henson <steve@openssl.org>2016-04-29 21:36:14 +0100
commit64eaf6c928f4066d62aa86f805796ef05bd0b1cc (patch)
tree24c1df314d89385b5db909af0b9d7dac6923d926
parent9b08619cb45e75541809b1154c90e1a00450e537 (diff)
downloadopenssl-new-64eaf6c928f4066d62aa86f805796ef05bd0b1cc.tar.gz
Don't free ret->data if malloc fails.
Issue reported by Guido Vranken. Reviewed-by: Matt Caswell <matt@openssl.org>
-rw-r--r--crypto/asn1/a_bytes.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/asn1/a_bytes.c b/crypto/asn1/a_bytes.c
index 12715a7280..385b53986a 100644
--- a/crypto/asn1/a_bytes.c
+++ b/crypto/asn1/a_bytes.c
@@ -200,13 +200,13 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
} else {
if (len != 0) {
if ((ret->length < len) || (ret->data == NULL)) {
- if (ret->data != NULL)
- OPENSSL_free(ret->data);
s = (unsigned char *)OPENSSL_malloc((int)len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
}
+ if (ret->data != NULL)
+ OPENSSL_free(ret->data);
} else
s = ret->data;
memcpy(s, p, (int)len);