summaryrefslogtreecommitdiffstats
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:43:12 +0100
commit66ce2861c172b2eb344906f424e593337fbd1af8 (patch)
tree234327f11dd8a9aa0e839ab8cf4e8b346a30ff80
parent1c81a59503af23fa109e346c973e99c66222bf11 (diff)
Don't free ret->data if malloc fails.
Issue reported by Guido Vranken. Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 64eaf6c928f4066d62aa86f805796ef05bd0b1cc)
-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);